Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hello-nrfcloud/lambda-helpers
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.3
Choose a base ref
...
head repository: hello-nrfcloud/lambda-helpers
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.4
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Mar 6, 2025

  1. fix(problemResponse): handle response validation case first

    coderbyheart committed Mar 6, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c07e8f0 View commit details
Showing with 7 additions and 10 deletions.
  1. +7 −10 src/problemResponse.ts
17 changes: 7 additions & 10 deletions src/problemResponse.ts
Original file line number Diff line number Diff line change
@@ -19,10 +19,7 @@ export class ProblemDetailError extends Error {
public readonly problem: Static<typeof ProblemDetail>
constructor(problem: Omit<Static<typeof ProblemDetail>, '@context'>) {
super(problem.title)
this.problem = {
'@context': Context.problemDetail.toString(),
...problem,
}
this.problem = { '@context': Context.problemDetail.toString(), ...problem }
this.name = 'ProblemDetailError'
}
}
@@ -35,16 +32,16 @@ export const problemResponse = (): MiddlewareObj<
> => ({
onError: async (req) => {
if (req.response !== undefined) return
if (req.error instanceof ValidationFailedError) {
if (req.error instanceof ResponseValidationFailedError) {
req.response = aProblem({
title: 'Validation failed',
status: HttpStatusCode.BAD_REQUEST,
title: 'Response validation failed',
status: HttpStatusCode.INTERNAL_SERVER_ERROR,
detail: formatTypeBoxErrors(req.error.errors),
})
} else if (req.error instanceof ResponseValidationFailedError) {
} else if (req.error instanceof ValidationFailedError) {
req.response = aProblem({
title: 'Response validation failed',
status: HttpStatusCode.INTERNAL_SERVER_ERROR,
title: 'Validation failed',
status: HttpStatusCode.BAD_REQUEST,
detail: formatTypeBoxErrors(req.error.errors),
})
} else if (req.error instanceof ProblemDetailError) {