File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " strontium" ,
3
- "version" : " 2.2.3 " ,
3
+ "version" : " 2.2.4 " ,
4
4
"description" : " Strontium is a TypeScript toolkit for High Performance API servers built for Production not Projects." ,
5
5
"main" : " lib/src/index.js" ,
6
6
"types" : " lib/src/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -17,4 +17,12 @@ export abstract class HTTPError extends StrontiumError {
17
17
errorMessage : this . externalMessage ,
18
18
}
19
19
}
20
+
21
+ public static isHTTPError ( e : any ) : e is HTTPError {
22
+ return (
23
+ e !== undefined &&
24
+ typeof e . statusCode === "number" &&
25
+ typeof e . toResponseBody === "function"
26
+ )
27
+ }
20
28
}
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ export class FastifyServer implements Process {
189
189
} catch ( e ) {
190
190
// Detect Input Validation issues.
191
191
// Any other errors will be thrown directly if they are HTTPError compatible or 500 and logged if not.
192
- if ( e instanceof HTTPError ) {
192
+ if ( HTTPError . isHTTPError ( e ) ) {
193
193
response . code ( e . statusCode )
194
194
return e . toResponseBody ( )
195
195
} else {
You can’t perform that action at this time.
0 commit comments