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 1
1
import { formatTypeBoxErrors } from '@hello.nrfcloud.com/proto'
2
2
import {
3
+ Context ,
3
4
HttpStatusCode ,
4
5
type ProblemDetail ,
5
6
} from '@hello.nrfcloud.com/proto/hello'
@@ -8,16 +9,19 @@ import type { Static } from '@sinclair/typebox'
8
9
import type {
9
10
APIGatewayProxyEventV2 ,
10
11
APIGatewayProxyStructuredResultV2 ,
11
- Context ,
12
+ Context as LambdaContext ,
12
13
} from 'aws-lambda'
13
14
import { aProblem } from './aProblem.js'
14
15
import { ValidationFailedError } from './validateInput.js'
15
16
16
17
export class ProblemDetailError extends Error {
17
18
public readonly problem : Static < typeof ProblemDetail >
18
- constructor ( problem : Static < typeof ProblemDetail > ) {
19
+ constructor ( problem : Omit < Static < typeof ProblemDetail > , '@context' > ) {
19
20
super ( problem . title )
20
- this . problem = problem
21
+ this . problem = {
22
+ '@context' : Context . problemDetail . toString ( ) ,
23
+ ...problem ,
24
+ }
21
25
this . name = 'ProblemDetailError'
22
26
}
23
27
}
@@ -26,7 +30,7 @@ export const problemResponse = (): MiddlewareObj<
26
30
APIGatewayProxyEventV2 ,
27
31
APIGatewayProxyStructuredResultV2 ,
28
32
Error ,
29
- Context
33
+ LambdaContext
30
34
> => ( {
31
35
onError : async ( req ) => {
32
36
if ( req . error instanceof ValidationFailedError ) {
You can’t perform that action at this time.
0 commit comments