Exception: Servus::Support::Errors::GuardError
- Inherits:
-
ServiceError
- Object
- StandardError
- ServiceError
- Servus::Support::Errors::GuardError
- Defined in:
- lib/servus/support/errors.rb
Overview
Guard validation failure with custom code.
Guards define their own error code and HTTP status via the DSL.
Constant Summary collapse
- DEFAULT_MESSAGE =
'Guard validation failed'
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
Application-specific error code.
-
#http_status ⇒ Symbol, Integer
readonly
HTTP status code.
Attributes inherited from ServiceError
Instance Method Summary collapse
- #api_error ⇒ Object
-
#initialize(message = nil, code: 'guard_failed', http_status: :unprocessable_entity) ⇒ GuardError
constructor
Creates a new guard error with metadata.
Constructor Details
#initialize(message = nil, code: 'guard_failed', http_status: :unprocessable_entity) ⇒ GuardError
Creates a new guard error with metadata.
129 130 131 132 133 |
# File 'lib/servus/support/errors.rb', line 129 def initialize( = nil, code: 'guard_failed', http_status: :unprocessable_entity) super() @code = code @http_status = http_status end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns application-specific error code.
119 120 121 |
# File 'lib/servus/support/errors.rb', line 119 def code @code end |
#http_status ⇒ Symbol, Integer (readonly)
Returns HTTP status code.
122 123 124 |
# File 'lib/servus/support/errors.rb', line 122 def http_status @http_status end |
Instance Method Details
#api_error ⇒ Object
135 |
# File 'lib/servus/support/errors.rb', line 135 def api_error = { code: code, message: } |