-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix koa ValidateError #1521
Fix koa ValidateError #1521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello there hpx7 👋
Thank you and congrats 🎉 for opening your first PR on this project.✨
We will review the following PR soon! 👀
@WoH would you be able to provide any guidance on the testing strategy for this? |
The |
I think most of the invalid JSON errors are a consequence tbh. |
@@ -92,7 +92,7 @@ export function RegisterRoutes(router: KoaRouter) { | |||
} catch (err) { | |||
const error = err as any; | |||
context.status = error.status; | |||
context.throw(error.status, JSON.stringify({ fields: error.fields })); | |||
context.throw(context.status, error.message, error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just rethrow, right?
And set expose to true:
https://github.com/koajs/koa/blob/master/docs/api/context.md#ctxthrowstatus-msg-properties
@WoH I managed to track down and fix the tests |
The current test failures seem related to some dependency upgrade. Any ideas @WoH? EDIT: The failure is that the test expects |
Yup, seems unrelated. I'll check what went wrong. |
Any luck so far @WoH ? Let me know if I can help |
Closes #1333
All Submissions:
Closing issues
Put
closes #XXXX
(where XXXX is the issue number) in your comment to auto-close the issue that your PR fixes.If this is a new feature submission:
Potential Problems With The Approach
Test plan
I have verified this patch in my local tsoa + koa project