-
-
Notifications
You must be signed in to change notification settings - Fork 416
Incompatibility between servant-server and Vanilla JS generator on server-side errors #296
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
Comments
Edit: Moved this comment to #294 |
Relating to this, is there a way to return JSON encodable errors using |
Something like
Such that I don't think it would be too hard to implement. Right? |
Yes, that looks great, @arianvp. To clarify, does type UserAPI = "users" :> QueryParam "sortby" SortBy :> Get '[JSON] [User]
^^^^^^^^^^^^^^ I’d give it a shot to implement but I am still a beginner Haskell programmer. Happy to help in other ways though: I have quite a bit of experience building REST APIs with other languages, so I can share that and could also help out with docs, etc. Let me know. |
I'm not entirely sure we could have a fully polymorphic
|
REST API error handling: {
"error": {
"message": "Message describing the error",
"type": "OAuthException",
"code": 190,
"error_subcode": 460,
"error_user_title": "A title",
"error_user_msg": "A message",
"fbtrace_id": "EJplcsCHuLu"
}
} {
"errors": [
{
"message": "Sorry, that page does not exist",
"code": 34
}
]
} |
@gasi Yes it does. Check out the tutorial, it explains how |
@arianvp 👍 I’ll check it out. |
Hi.
When any endpoint on servant-server returns a
ServantErr
, it just puts theerrBody
as is. But the JS client generated withservant-js
expects a JSON object and tries to decode it; then it fails with a syntax error.I think either the server should encode the errors conforming with
Content-type
, or generated JavaScript client must not convert it from JSON and just give the response body to error callback.Example:
When calling the API with generated JavaScript, instead of calling the error handler, it fails with syntax error.
The text was updated successfully, but these errors were encountered: