-
Notifications
You must be signed in to change notification settings - Fork 398
Closed
Labels
status: awaiting answerAwaiting answer from the author of issue or PR.Awaiting answer from the author of issue or PR.type: questionQuestions about the usage of the library.Questions about the usage of the library.
Description
Hi there
I noticed that if I throw an error inside of a route, it is caught and the client receives a JSON body response. But if I throw an error inside of some middleware, UseBefore the route, then the error is returned as the body of the response.
For example, this is the body of the response from a custom middleware (AuthrizePlayer) that throws an error:
Error
at AuthorizePlayer.use (C:\Users\Tim\Desktop\Heroku\cargame2020\dist\Middleware\AuthorizePlayer.js:6:15)
at C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\routing-controllers\driver\express\ExpressDriver.js:381:86
at Layer.handle [as handle_request]
(C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request]
(C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\middleware\init.js:40:5)
at Layer.handle [as handle_request]
(C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:317:13)
at C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:284:7
at Function.process_params (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\router\index.js:275:10)
at query (C:\Users\Tim\Desktop\Heroku\cargame2020\node_modules\express\lib\middleware\query.js:45:5)
Compared to the same error (new Error()) being throw inside of the route itself:
{
"name": "Error",
"stack": "Error\n at PlayerController.GetMyName (C:\\Users\\Tim\\Desktop\\Heroku\\cargame2020\\dist\\Controllers\\PlayerController.js:40:19)\n at ActionMetadata.callMethod (C:\\Users\\Tim\\Desktop\\Heroku\\cargame2020\\node_modules\\routing-controllers\\metadata\\ActionMetadata.js:108:48)\n at C:\\Users\\Tim\\Desktop\\Heroku\\cargame2020\\node_modules\\routing-controllers\\RoutingControllers.js:99:140"
}
sharrief, marines, Kalhama and ThePooN
Metadata
Metadata
Assignees
Labels
status: awaiting answerAwaiting answer from the author of issue or PR.Awaiting answer from the author of issue or PR.type: questionQuestions about the usage of the library.Questions about the usage of the library.