Error response not being set
Closed this issue · 3 comments
Throwing an error always results in code 500 and "server error" as the message.
I've tried
throw {
code: "invalid_argument",
msg: "",
};
throw TwirpErrorResponse({
code: "invalid_argument",
msg: "",
});
All of these produced code 500 and "server error".
I've also tried replacing throw
with return
but this gives a response of 200 and empty body.
I'm also running v0.0.37 if that makes a difference
Hey @antonioorct, I've updated the documentation in this PR: #107.
the tldr is that you'll want to use
throw new TwirpError({
code: "invalid_argument",
msg: "",
}
Let me know if you still encounter any issues. Also, any reason you're running v0.0.37
?
@tatethurston i usually update when you add a feature that i need or fix a bug as i don't want to deal with changing my code unnecessarily because of breaking changes
I've upgraded to v0.0.42 because typescript was throwing an error with your answer with my previous version, but now it works, thanks!