Handle error code in BeditaException #719

edoardocavazza opened this Issue Jun 26, 2015 · 1 comment


None yet

3 participants


Sometimes, understand why an exception has been thrown from the http status code is not enough.

Real cases

  • Loading an object using its ID, can throw a 404 not found exception if the requested object does not exist or any related object fails to load.
  • Request a poster image for an object can throw 404 if the object does not exist or the poster is missing.

We could handle the cases using a specific error code.

Error codes naming proposals:

  1. generic incremental codes
  2. incremental codes associated with http status (we could have a NotFoundException with error code 0 and a BeditaUnauthorizedException with the same code and different meaning)
  3. incremental codes prefixed with http status
  4. categorized error codes (0-100 core errors, 100-200 vendors errors, 200-300 file errors)

I would prefer to use the second option, where 0 is always the blocking error code that sets the error layout.

@batopa @stefanorosanelli @fquffio
What are your opinions?

@edoardocavazza edoardocavazza added this to the 3-updates milestone Jun 26, 2015
batopa commented Jun 26, 2015

Uhm... maybe to have a unique error code is better to know always what kind of error was thrown. The HTTP status code could help to know what operation was been tried.

For example if error code 10 means "Missing object related" you know that when server responds with that code the error is always the same. The HTTP status instead will give information depending from request type for eample a 404 if a GET operation was done or 500 if a POST operation was done.

@stefanorosanelli stefanorosanelli removed this from the 4-release milestone May 20, 2016
@batopa batopa added this to the 3-updates milestone Sep 23, 2016
@batopa batopa added the Status - PR label Sep 23, 2016
@batopa batopa added a commit that referenced this issue Sep 26, 2016
@batopa batopa #719 feat: add class to handle error code
It makes throw exception with error code more flexible
@batopa batopa closed this Oct 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment