Can we clean up the error responses and not have it return the frames array? Just message, name, status?
Ready to get started?
Join Adocasts Plus for $8/mo, or sign into an existing Adocasts Plus account, to get access to all of our lessons.
API Authorization Checks
We'll implement our API Authorization checks across all the API controller methods we've implemented thus far. We'll then create a specific access token for each operation (read, create, update, and delete) to ensure everything is working.
- Created by
- @tomgobich
- Published
Join the Discussion 2 comments
-
-
Responding to aaron-ford
Ah - it didn't occur to me, but I should've noted this in the lesson. Similar to the HTML Youch page, the
frameshere is only included in when debugging. It should be omitted when your application is running on production. I believe onlymessageis included in production.If you do wish to customize the exception, though, you can do that within the exception's
handlemethod. This can be done globally within thehandle.tsmethod or any individual custom exceptions. You can also narrow in on a specific exception withinhandle.tsas well:/** * The method is used for handling errors and returning * response to the client */ async handle(error: unknown, ctx: HttpContext) { if (error instanceof errors.E_HTTP_EXCEPTION) { return ctx.response.status(error.status).send({ message: 'Oh no!' }) } return super.handle(error, ctx) }Copied!0
-