@@ -19,10 +19,7 @@ export class ProblemDetailError extends Error {
1919 public readonly problem : Static < typeof ProblemDetail >
2020 constructor ( problem : Omit < Static < typeof ProblemDetail > , '@context' > ) {
2121 super ( problem . title )
22- this . problem = {
23- '@context' : Context . problemDetail . toString ( ) ,
24- ...problem ,
25- }
22+ this . problem = { '@context' : Context . problemDetail . toString ( ) , ...problem }
2623 this . name = 'ProblemDetailError'
2724 }
2825}
@@ -35,16 +32,16 @@ export const problemResponse = (): MiddlewareObj<
3532> => ( {
3633 onError : async ( req ) => {
3734 if ( req . response !== undefined ) return
38- if ( req . error instanceof ValidationFailedError ) {
35+ if ( req . error instanceof ResponseValidationFailedError ) {
3936 req . response = aProblem ( {
40- title : 'Validation failed' ,
41- status : HttpStatusCode . BAD_REQUEST ,
37+ title : 'Response validation failed' ,
38+ status : HttpStatusCode . INTERNAL_SERVER_ERROR ,
4239 detail : formatTypeBoxErrors ( req . error . errors ) ,
4340 } )
44- } else if ( req . error instanceof ResponseValidationFailedError ) {
41+ } else if ( req . error instanceof ValidationFailedError ) {
4542 req . response = aProblem ( {
46- title : 'Response validation failed' ,
47- status : HttpStatusCode . INTERNAL_SERVER_ERROR ,
43+ title : 'Validation failed' ,
44+ status : HttpStatusCode . BAD_REQUEST ,
4845 detail : formatTypeBoxErrors ( req . error . errors ) ,
4946 } )
5047 } else if ( req . error instanceof ProblemDetailError ) {
0 commit comments