Skip to content
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

Error detail thrown away if error title is set #269

Open
mstahl opened this issue Aug 18, 2017 · 1 comment
Open

Error detail thrown away if error title is set #269

mstahl opened this issue Aug 18, 2017 · 1 comment

Comments

@mstahl
Copy link

mstahl commented Aug 18, 2017

https://github.com/chingor13/json_api_client/blob/master/lib/json_api_client/resource.rb#L414-L418

Those lines where errors are added to the returned object hide the error details if the API returns an error title. From the standard, the title attribute may be set, but shouldn't ever change from instance to instance of a problem, so including the title tells you only what kind of error happened, not any specifics of it. The detail attribute is also optional but is meant to give details about the error.

The specific error that's causing this for me is a 400 response where the title is "Param not allowed". That's the title that my server is returning, so that's OK, but the detail attribute tells which param it was that wasn't allowed. Without that information the error message is not very helpful, and useful information my API is returning gets thrown out.

Recommend changing that so that it either appends the two together if both are set, displays detail over title (reverse the two terms so that detail takes priority), or allow that to be a setting so users can choose one way or the other. I'm happy to submit a pull request with any of these options but probably the simplest and least objectionable is the first option.

@mstahl
Copy link
Author

mstahl commented Aug 26, 2017

I made a PR for this that just concats title and detail together with a hyphen between: #272

@mstahl mstahl closed this as completed Aug 26, 2017
@mstahl mstahl reopened this Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant