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

Include docs regarding RestException details and custom error handling #526

Closed
2 tasks
igorsantos07 opened this issue Feb 5, 2016 · 2 comments
Closed
2 tasks
Assignees

Comments

@igorsantos07
Copy link

igorsantos07 commented Feb 5, 2016

  • There's no docs regarding the third argument usage on RestException. Initially I was overwriting Restler::message() so I could have custom error returns, including details manually - passing them through RestException made no difference. Later, when overwriting Compose (as per Document iCompose usage #522), I discovered how the third argument works: you must pass an array, that is going to be merged to the main error object. Sample: throw new RestException(404, 'Filters returned no results', ['details' => [$begin, $end]]).
  • There's no docs as well about custom error handling classes. I stumbled upon them in the source, just like it happened with the point above. However, I'm still not sure how to deal with them in my case at least, since my API classes might throw database exceptions, and I would like to catch them and turn into RestException instances (such as ModelNotFound = 404, InvalidModelException = 422, etc).

Discussion: would it be clearer if the third argument was appended as "details" instead of merged? This way we would not need to specify keys (or even an array, as it is now), and it would make for more standardized APIs (always with error + message + (optional) details).

@Arul-
Copy link
Member

Arul- commented Feb 7, 2016

Please help us document these in Trello

https://trello.com/b/UgKyJkYL/restler-3

All the documentation requirements shall be added to https://trello.com/c/lKqRMaHE/4-restler-3-examples

@Arul-
Copy link
Member

Arul- commented Aug 3, 2021

@Arul- Arul- closed this as completed Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants