Module: Layer::Exceptions

Defined in:
lib/layer/exceptions.rb

Defined Under Namespace

Classes: AccessDenied, AppSuspended, AuthenticationRequired, ClientException, Conflict, Exception, InternalServerError, InvalidAppId, InvalidEndpoint, InvalidHeader, InvalidOperation, InvalidProperty, InvalidRequest, InvalidRequestId, MissingProperty, NotFound, ObjectDeleted, RateLimitExceeded, RequestTimeout, ResourceException, ServiceUnavailable, UserSuspended

Class Method Summary collapse

Class Method Details

.build_exception(original_exception) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/layer/exceptions.rb', line 4

def self.build_exception(original_exception)
  identifier = JSON.parse(original_exception.http_body)['id']
  identifier.gsub!(/(?:_|(\/)|^)([a-z\d]*)/i) { $2.capitalize }

  exception = const_get(identifier) rescue Exception
  exception.new(original_exception)
rescue
  original_exception
end