rocket_pants core

The inner core of Rocket Pants 2.0 - Error handling primarily.

3
1
Ruby

RocketPants Core

As part of RocketPants, this repository contains the core code that handles
error to exception mapping and anything common between client and server.

On it’s own, not super useful. But when used in combination with Rocket Pants,
this lets you build client and server stuff.

RocketPants::Error

RocketPants::Error is a StandardError subclass designed for being mappable into
a client HTTP response. Namely, exceptions can be associated with:

  • An error name
  • A http status code (e.g. 422)
  • Optionally, any extra context

RocketPants::Errors

Provides a register mapping symbolic error names to RocketPants::Error sub classes.
Included in this is a set of default exception classes.

Built-in Errors

Error Key Exception Class HTTP Status Description
:throttled RocketPants::Throttled 503 Unavailable The user has hit an api throttled error.
:unauthenticated RocketPants::Unauthenticated 401 Unauthorized The user doesn't have valid authentication details.
:invalid_version RocketPants::Invalidversion 404 Not Found An invalid API version was specified.
:not_implemented RocketPants::NotImplemented 503 Unavailable The specified endpoint is not yet implemented.
:not_found RocketPants::NotFound 404 Not Found The given resource could not be found.
:invalid_resource RocketPants::InvalidResource 422 Unprocessable Entity The given resource was invalid.
:bad_request RocketPants::BadRequest 400 Bad Request The given request was not as expected.
:conflict RocketPants::Conflict 409 Conflict The resource was a conflict with the existing version.
:forbidden RocketPants::Forbidden 403 Forbidden The requested action was forbidden.