本文整理匯總了TypeScript中main/common/errorHandling.ErrorHandling類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ErrorHandling類的具體用法?TypeScript ErrorHandling怎麽用?TypeScript ErrorHandling使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ErrorHandling類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildRouter
buildRouter (path: string, ...guards: express.RequestHandler[]): express.Router {
return express.Router()
.get(
path + Paths.paidAmountPage.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
this.renderView(new Form(this.paidAmount().get(res.locals.draft.document)), res)
}))
.post(
path + Paths.paidAmountPage.uri,
FormValidator.requestHandler(PaidAmount, PaidAmount.fromObject),
ErrorHandling.apply(
async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<PaidAmount> = req.body
if (form.hasErrors()) {
this.renderView(form, res)
} else {
this.paidAmount().set(res.locals.draft.document, form.model)
const user: User = res.locals.user
await new DraftService().save(res.locals.draft, user.bearerToken)
const { externalId } = req.params
res.redirect(new RoutablePath(path + Paths.paidAmountSummaryPage.uri).evaluateUri({ externalId: externalId }))
}
}))
}
示例2: buildRouter
buildRouter (path: string, ...guards: express.RequestHandler[]): express.Router {
return express.Router()
.get(path + Paths.paymentOptionPage.uri,
...guards,
(req: express.Request, res: express.Response) => {
this.renderView(new Form(this.createModelAccessor().get(res.locals.draft.document).paymentOption), res)
})
.post(path + Paths.paymentOptionPage.uri,
...guards,
FormValidator.requestHandler(PaymentOption, PaymentOption.fromObject),
ErrorHandling.apply(
async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<PaymentOption> = req.body
if (form.hasErrors()) {
this.renderView(form, res)
} else {
this.createModelAccessor().patch(res.locals.draft.document, model => model.paymentOption = form.model)
this.deleteRedundantData(res, req)
await this.saveDraft(res.locals)
res.redirect(this.buildPostSubmissionUri(path, req, res))
}
}))
}
示例3: buildRouter
buildRouter (path: string, ...guards: express.RequestHandler[]): express.Router {
return express.Router()
.get(
path + FreeMediationPaths.freeMediationPage.uri,
...guards,
(req: express.Request, res: express.Response) => {
const draft: Draft<any> = res.locals.draft
this.renderView(new Form(draft.document.freeMediation), res)
})
.post(
path + FreeMediationPaths.freeMediationPage.uri,
...guards,
FormValidator.requestHandler(FreeMediation),
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
const form: Form<FreeMediation> = req.body
if (form.hasErrors()) {
this.renderView(form, res)
} else {
const draft: Draft<any> = res.locals.draft
const user: User = res.locals.user
draft.document.freeMediation = form.model
await new DraftService().save(draft, user.bearerToken)
res.redirect(this.buildRedirectUri(req, res))
}
}))
}
示例4: buildRouter
buildRouter (path: string, ...guards: express.RequestHandler[]): express.Router {
return express.Router()
.get(
path + Paths.paidAmountSummaryPage.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
const claim: Claim = res.locals.claim
const model = this.paidAmount().get(res.locals.draft.document)
res.render(
this.getView(), {
claim: claim,
alreadyPaid: model.amount || 0,
interestDetails: await getInterestDetails(claim),
nextPageUrl: this.buildRedirectUri(req, res),
defaultJudgmentDate: MomentFactory.currentDate(),
amountSettledFor: this.amountSettledFor(claim, res.locals.draft.document)
}
)
}))
}
示例5: Form
const draft: Draft<ResponseDraft> = res.locals.responseDraft
res.render(page.associatedView, {
form: new Form(draft.document.statementOfMeans.partnerPension)
})
})
.post(
page.uri,
StatementOfMeansStateGuard.requestHandler(),
FormValidator.requestHandler(PartnerPension),
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const form: Form<PartnerPension> = req.body
const { externalId } = req.params
if (form.hasErrors()) {
res.render(page.associatedView, { form: form })
} else {
const draft: Draft<ResponseDraft> = res.locals.responseDraft
const user: User = res.locals.user
draft.document.statementOfMeans.partnerPension = form.model
await new DraftService().save(draft, user.bearerToken)
if (draft.document.statementOfMeans.disability && draft.document.statementOfMeans.disability.option === DisabilityOption.YES) {
res.redirect(StatementOfMeansPaths.partnerDisabilityPage.evaluateUri({ externalId: externalId }))
} else {
res.redirect(StatementOfMeansPaths.dependantsPage.evaluateUri({ externalId: externalId }))
}
}
})
)
示例6: getPayBySetDate
const payBySetDate = getPayBySetDate(draft, claimResponse)
res.render(Paths.courtOfferedSetDatePage.associatedView, {
form: form,
claim: claim,
paymentDate: payBySetDate
})
}
/* tslint:disable:no-default-export */
export default express.Router()
.get(
Paths.courtOfferedSetDatePage.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
renderView(new Form(draft.document.acceptCourtOffer), res)
}))
.post(
Paths.courtOfferedSetDatePage.uri,
FormValidator.requestHandler(AcceptCourtOffer, AcceptCourtOffer.fromObject),
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
const form: Form<AcceptCourtOffer> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
const user: User = res.locals.user
const { externalId } = req.params
示例7: renderView
function renderView (form: Form<ClaimSettled>, res: express.Response): void {
const claim: Claim = res.locals.claim
res.render(Paths.settleClaimPage.associatedView,{
form: form,
totalAmount: StatesPaidHelper.getAlreadyPaidAmount(claim),
paidInFull: !StatesPaidHelper.isAlreadyPaidLessThanAmount(claim)
})
}
/* tslint:disable:no-default-export */
export default express.Router()
.get(Paths.settleClaimPage.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
renderView(new Form(draft.document.accepted), res)
}))
.post(
Paths.settleClaimPage.uri,
FormValidator.requestHandler(ClaimSettled, ClaimSettled.fromObject),
ErrorHandling.apply(async (req: express.Request, res: express.Response): Promise<void> => {
const form: Form<ClaimSettled> = req.body
if (form.hasErrors()) {
renderView(form, res)
} else {
const draft: Draft<DraftClaimantResponse> = res.locals.claimantResponseDraft
draft.document.accepted = form.model
if (form.model.accepted.option === YesNoOption.YES.option) {
draft.document.rejectionReason = undefined
draft.document.freeMediation = undefined
示例8: catch
form: form,
claim: claim,
offer: claim.settlement.getLastOffer(),
name: 'option'
})
} catch (err) {
next(err)
}
}
/* tslint:disable:no-default-export */
export default express.Router()
.get(
Paths.signSettlementAgreement.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction) => {
renderView(new Form(new DefendantSettlementResponse()), res, next)
}))
.post(
Paths.signSettlementAgreement.uri,
FormValidator.requestHandler(DefendantSettlementResponse),
ErrorHandling.apply(async (req: express.Request, res: express.Response, next: express.NextFunction): Promise<void> => {
const form: Form<DefendantSettlementResponse> = req.body
if (form.hasErrors()) {
renderView(form, res, next)
} else {
const claim: Claim = res.locals.claim
const user: User = res.locals.user
if (form.model.option === YesNoOption.YES.option) {
await settlementAgreementClient.countersignSettlementAgreement(claim.externalId, user)
示例9: renderView
import { Paths } from 'mediation/paths'
import { ErrorHandling } from 'main/common/errorHandling'
import { User } from 'idam/user'
import { Claim } from 'claims/models/claim'
import { ClaimFeatureToggles } from 'utils/claimFeatureToggles'
function renderView (res: express.Response): void {
const user: User = res.locals.user
const claim: Claim = res.locals.claim
res.render(Paths.freeMediationPage.associatedView, {
otherParty: claim.otherPartyName(user),
defendant: user.id === claim.defendantId,
mediationPilot: ClaimFeatureToggles.isFeatureEnabledOnClaim(res.locals.claim, 'mediationPilot')
})
}
/* tslint:disable:no-default-export */
export default express.Router()
.get(Paths.freeMediationPage.uri, (req: express.Request, res: express.Response) => {
renderView(res)
})
.post(
Paths.freeMediationPage.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
const claim: Claim = res.locals.claim
res.redirect(Paths.howMediationWorksPage.evaluateUri({ externalId: claim.externalId }))
}))
示例10: DraftService
.post(
Paths.mediationAgreementPage.uri,
ErrorHandling.apply(async (req: express.Request, res: express.Response) => {
const claim: Claim = res.locals.claim
const draft: Draft<MediationDraft> = res.locals.mediationDraft
const user: User = res.locals.user
if (req.body.accept) {
draft.document.youCanOnlyUseMediation = new FreeMediation(FreeMediationOption.YES)
await new DraftService().save(draft, user.bearerToken)
if (claim.claimData.defendant.isBusiness()) {
res.redirect(Paths.canWeUseCompanyPage.evaluateUri({ externalId: claim.externalId }))
} else {
res.redirect(Paths.canWeUsePage.evaluateUri({ externalId: claim.externalId }))
}
} else {
draft.document.youCanOnlyUseMediation = new FreeMediation(FreeMediationOption.NO)
draft.document.canWeUse = undefined
draft.document.canWeUseCompany = undefined
await new DraftService().save(draft, user.bearerToken)
if (!claim.isResponseSubmitted()) {
res.redirect(ResponsePaths.taskListPage.evaluateUri({ externalId: claim.externalId }))
} else {
res.redirect(ClaimantResponsePaths.taskListPage.evaluateUri({ externalId: claim.externalId }))
}
}
}))