File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import packageJson from "../package.json" with {type: "json"};
44import { Request } from "./Request.js" ;
55import { EmptyResponse } from "./response/index.js" ;
66import { Response } from "./response/Response.js" ;
7+ import { ThrowableResponse } from "./response/ThrowableResponse.js" ;
78import { RouteRegistry } from "./routing/RouteRegistry.js" ;
89import { ServerErrorRegistry } from "./ServerErrorRegistry.js" ;
910
@@ -100,7 +101,13 @@ class Server extends EventEmitter<Server.Events> {
100101 response = await this . routes . handle ( apiRequest ) ;
101102 }
102103 catch ( e ) {
103- if ( e instanceof RouteRegistry . NoRouteError )
104+ if ( e instanceof ThrowableResponse ) {
105+ response = e . getResponse ( ) ;
106+ const cause = e . getError ( ) ;
107+ if ( cause !== null )
108+ this . emit ( "error" , cause ) ;
109+ }
110+ else if ( e instanceof RouteRegistry . NoRouteError )
104111 response = this . errors . _get ( ServerErrorRegistry . ErrorCodes . NO_ROUTE , apiRequest ) ;
105112 else {
106113 this . emit ( "error" , e as any ) ;
You can’t perform that action at this time.
0 commit comments