Descriptive Exceptions

Description

I've had a couple of conversations with @heiglandreas and @asgrim which have raised a couple of interesting points:

  • HTTP Response codes on the API are a little inconsistent

  • We are only using base Exceptions, which makes writing tests harder (we can't check for a specific type of Exception, and end up resorting to checking the message returned by the exception, which isn't ideal)

It's probably worth looking at putting together our own list of Exception types and replacing the Exceptions in the API to use them - that way:

  • We can ensure consistency by setting the response code within the Exception

  • We can write tests to check for the correct Exception Type in each case.

As a starting point, we should come up with a list of 'needed' Exceptions and status codes - Exception design isn't something I've done before, so I've come up with a list, but it's open to comments:

InvalidPayloadException - 400
NoAccessException - 403
NoDataException - 422
NotFoundException - 404
UnauthorizedException - 401

Discuss

Activity

Show:

Details

Assignee

Reporter

Components

Priority

Created October 6, 2016 at 8:35 AM
Updated October 6, 2016 at 8:35 AM