Exception: Core::Exceptions::OpaqueError
- Defined in:
- lib/svcbase/exceptions.rb
Overview
Opaque errors should write their msg to the log, but should not return any useful data to the caller.
Note that the raise syntax is different for these messages, since they only take a single logmsg and an optional loglevel.
Examples:
raise Exceptions::Fatal
raise Exceptions::Fatal, 'Something is amiss'
raise Exceptions::Fatal, 'Something is awry', loglevel: warn
# still returns a 500 internal server error but logs at warn instead of fatal
Direct Known Subclasses
Constant Summary
Constants inherited from Error
Error::DEFAULT_LOGLEVEL, Error::DEFAULT_MSGCODE, Error::MESSAGE_SCOPE, Error::STATUS
Instance Attribute Summary
Attributes inherited from Error
#details, #headers, #loglevel, #msgcode, #msgobj
Instance Method Summary collapse
-
#initialize(logmsg = 'UNKNOWN', loglevel: nil) ⇒ OpaqueError
constructor
A new instance of OpaqueError.
- #response ⇒ Object
Methods inherited from Error
classname, default_loglevel, default_msgcode, #logmsg, #status
Constructor Details
#initialize(logmsg = 'UNKNOWN', loglevel: nil) ⇒ OpaqueError
Returns a new instance of OpaqueError.
145 146 147 148 |
# File 'lib/svcbase/exceptions.rb', line 145 def initialize(logmsg = 'UNKNOWN', loglevel: nil) raise "new not allowed for #{self.class}" if self.class == Exceptions::OpaqueError super(self.class.default_msgcode, logmsg: logmsg, loglevel: loglevel) end |
Instance Method Details
#response ⇒ Object
150 151 152 |
# File 'lib/svcbase/exceptions.rb', line 150 def response { status: :error, error: { code: msgcode } } end |