File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 11import { formatTypeBoxErrors } from '@hello.nrfcloud.com/proto'
22import {
3+ Context ,
34 HttpStatusCode ,
45 type ProblemDetail ,
56} from '@hello.nrfcloud.com/proto/hello'
@@ -8,16 +9,19 @@ import type { Static } from '@sinclair/typebox'
89import type {
910 APIGatewayProxyEventV2 ,
1011 APIGatewayProxyStructuredResultV2 ,
11- Context ,
12+ Context as LambdaContext ,
1213} from 'aws-lambda'
1314import { aProblem } from './aProblem.js'
1415import { ValidationFailedError } from './validateInput.js'
1516
1617export class ProblemDetailError extends Error {
1718 public readonly problem : Static < typeof ProblemDetail >
18- constructor ( problem : Static < typeof ProblemDetail > ) {
19+ constructor ( problem : Omit < Static < typeof ProblemDetail > , '@context' > ) {
1920 super ( problem . title )
20- this . problem = problem
21+ this . problem = {
22+ '@context' : Context . problemDetail . toString ( ) ,
23+ ...problem ,
24+ }
2125 this . name = 'ProblemDetailError'
2226 }
2327}
@@ -26,7 +30,7 @@ export const problemResponse = (): MiddlewareObj<
2630 APIGatewayProxyEventV2 ,
2731 APIGatewayProxyStructuredResultV2 ,
2832 Error ,
29- Context
33+ LambdaContext
3034> => ( {
3135 onError : async ( req ) => {
3236 if ( req . error instanceof ValidationFailedError ) {
You can’t perform that action at this time.
0 commit comments