jgraichen / restify

Restify is a experimental, parallel and pipelined Hypermedia API client
GNU Lesser General Public License v3.0
8 stars 2 forks source link

Add specific exceptions for typical HTTP status codes #17

Closed franzliedke closed 5 years ago

franzliedke commented 5 years ago

This means specific errors can be handled directly by rescuing specific exception classes, instead of rescuing e.g. Restify::ClientError and then checking the exception's code or status.

Open questions:

franzliedke commented 5 years ago

ping @mswart for input

mswart commented 5 years ago

@franzliedke Looks good. Would really like to use it.

mswart commented 5 years ago

I think the important error codes are implemented. Placing the exception classes side the parent class should work: like Restify::ClientError::NotFound

jgraichen commented 5 years ago

Naming? I'd like to avoid the ...Error suffix, if possible, but that would probably mean we need a new namespace. Can subclasses be nested in their own parent class' namespace?

Yes they can but I'd be fine with e.g. Restify::Unauthorized. There shouldn't by any collisions and it is much easier to write and read.

Which error types do we want to handle? (It's easy to add new types later.) I went through our services and added those that we handle in a special way anywhere.

Unless you want to auto generate classes from the Rack status code mapping I'm fine with adding only needed.

franzliedke commented 5 years ago

Okay, updated the class names as coordinated in person. Ready from my side. 😉