Exception: Noise::PublicError
- Inherits:
-
StandardError
- Object
- StandardError
- Noise::PublicError
- Defined in:
- lib/noise/public_error.rb
Overview
Base class for all api level errors
Direct Known Subclasses
NotFoundError, RateLimitError, UnprocessableEntityError, UnsupportedMediaTypeError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, message_or_options = nil) ⇒ PublicError
constructor
A new instance of PublicError.
- #inspect ⇒ String
- #message ⇒ String
- #responder_class ⇒ ExceptionResponder private
Constructor Details
#new(code, message) ⇒ PublicError #new(code, options) ⇒ PublicError
Returns a new instance of PublicError.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/noise/public_error.rb', line 34 def initialize(code, = nil) @code = code.to_sym case when Hash @options = @message = nil else @options = {} @message = end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
13 14 15 |
# File 'lib/noise/public_error.rb', line 13 def code @code end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/noise/public_error.rb', line 14 def @options end |
Class Method Details
.register_as(status, severity:) ⇒ Object
71 72 73 74 |
# File 'lib/noise/public_error.rb', line 71 def register_as(status, severity:) Noise::ExceptionResponder.register(name, status: status) Noise::Notification.register(name, severity: severity) end |
Instance Method Details
#inspect ⇒ String
52 53 54 |
# File 'lib/noise/public_error.rb', line 52 def inspect "#<#{self.class}: #{}>" end |
#message ⇒ String
47 48 49 |
# File 'lib/noise/public_error.rb', line 47 def @message.presence || I18n.t("noise.#{self.class.name.demodulize.underscore}.#{@code}", @options) end |
#responder_class ⇒ ExceptionResponder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 |
# File 'lib/noise/public_error.rb', line 58 def responder_class ExceptionResponder end |