Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Error and Exception handling #117

Closed
laoneo opened this issue Mar 27, 2017 · 2 comments
Closed

Error and Exception handling #117

laoneo opened this issue Mar 27, 2017 · 2 comments

Comments

@laoneo
Copy link
Contributor

laoneo commented Mar 27, 2017

As pr #116 revealed. We need to address how error and exception handling should be done in the new media manager. Only on client side or server side and client side or only server side. We need to define a procedure for the following errors:

  • PHP errors
  • Exceptions
  • Invalid data
  • Javascript errors
@dneukirchen
Copy link
Contributor

dneukirchen commented Mar 27, 2017

Imho errors should be handled on both client and server.
In the context of an api the server catches exceptions and transforms it to a proper http response with the correct http status code and an optional message.

The client picks up that status code and shows the error to the user (in most cases its best to show the already translated error message from the server response).

The most important status codes for us are:

  • Validation errors: 422 (including an errors array which describes the validation errors).
  • Authentication/Authorization errors: 401/403
  • Invalid arguments: 422 most of the time (sometimes 400 for bad requests)
  • Bad requests: 400
  • Internal Server errors: 500
  • Otherwise the server returns 200, 201 & 202 (rarely 204) depending on the context.

@laoneo
Copy link
Contributor Author

laoneo commented Mar 28, 2017

What do we do with exceptions which should not break the whole request? For example when we fetch image data here and it throws an exception. The whole request aborts and no data is represented on the client. Here it would be possible to just show a warning to the user.
Also with PHP error messages (notices, waringins and errors), they make the JSON response invalid. I suggest to add here an exception handler to catch them and transform them into exceptions.

laoneo pushed a commit that referenced this issue May 18, 2018
* com_user es6

* some changes

* Some changes

* TODO

*  re-adding all dependencies
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants