Exception: Servus::Support::Errors::ServiceError
- Inherits:
-
StandardError
- Object
- StandardError
- Servus::Support::Errors::ServiceError
- Defined in:
- lib/servus/support/errors.rb
Overview
Base error class for all Servus service errors.
Subclasses define their HTTP status via #http_status and their API response format via #api_error.
Direct Known Subclasses
AuthenticationError, BadGatewayError, BadRequestError, ConflictError, ExpectationFailedError, FailedDependencyError, ForbiddenError, GatewayTimeoutError, GoneError, GuardError, HttpVersionNotSupportedError, ImATeapotError, InsufficientStorageError, InternalServerError, LengthRequiredError, LockedError, LoopDetectedError, MethodNotAllowedError, MisdirectedRequestError, NetworkAuthenticationRequiredError, NotAcceptableError, NotExtendedError, NotFoundError, NotImplementedError, PayloadTooLargeError, PreconditionFailedError, PreconditionRequiredError, ProxyAuthenticationRequiredError, RangeNotSatisfiableError, RequestHeaderFieldsTooLargeError, RequestTimeoutError, ServiceUnavailableError, TooEarlyError, TooManyRequestsError, UnavailableForLegalReasonsError, UnprocessableEntityError, UnsupportedMediaTypeError, UpgradeRequiredError, UriTooLongError, VariantAlsoNegotiatesError
Constant Summary collapse
- DEFAULT_MESSAGE =
'An error occurred'
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#api_error ⇒ Hash
Returns an API-friendly error response.
-
#http_status ⇒ Symbol
Returns the HTTP status code for this error.
-
#initialize(message = nil) ⇒ ServiceError
constructor
Creates a new service error instance.
Constructor Details
#initialize(message = nil) ⇒ ServiceError
Creates a new service error instance.
41 42 43 44 |
# File 'lib/servus/support/errors.rb', line 41 def initialize( = nil) @message = || self.class::DEFAULT_MESSAGE super("#{self.class}: #{@message}") end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
34 35 36 |
# File 'lib/servus/support/errors.rb', line 34 def @message end |
Instance Method Details
#api_error ⇒ Hash
Returns an API-friendly error response.
54 |
# File 'lib/servus/support/errors.rb', line 54 def api_error = { code: http_status, message: } |
#http_status ⇒ Symbol
Returns the HTTP status code for this error.
49 |
# File 'lib/servus/support/errors.rb', line 49 def http_status = :bad_request |