Exception: StashCoreAPI::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/stash_core_api/error.rb

Overview

Base class for all errors emanating from Stash.

Constant Summary collapse

ClientError =

Raised when Stash returns a 4xx HTTP status code

Class.new(self)
BadRequest =

Raised when Stash returns the HTTP status code 400

Class.new(ClientError)
Unauthorized =

Raised when Stash returns the HTTP status code 401

Class.new(ClientError)
Forbidden =

Raised when Stash returns the HTTP status code 403

Class.new(ClientError)
NotFound =

Raised when Stash returns the HTTP status code 404

Class.new(ClientError)
MethodNotAllowed =

Raised when Stash returns the HTTP status code 405

Class.new(ClientError)
Conflict =

Raised when Stash returns the HTTP status code 409

Class.new(ClientError)
UnsupportedMediaType =

Raised when Stash returns the HTTP status code 415

Class.new(ClientError)
ERRORS =
{
  400 => StashCoreAPI::Error::BadRequest,
  401 => StashCoreAPI::Error::Unauthorized,
  403 => StashCoreAPI::Error::Forbidden,
  404 => StashCoreAPI::Error::NotFound,
  405 => StashCoreAPI::Error::MethodNotAllowed,
  409 => StashCoreAPI::Error::Conflict,
  415 => StashCoreAPI::Error::UnsupportedMediaType,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(body = {}) ⇒ StashCoreAPI::Error

Initializes a new Error object

Parameters:

  • message (Exception, String)
  • code (Integer)


45
46
47
48
# File 'lib/stash_core_api/error.rb', line 45

def initialize(body = {})
  message = body.fetch('errors', {}).fetch(0, {}).fetch('message', '')
  super(message)
end