Module: Railsmith::Errors
- Defined in:
- lib/railsmith/errors.rb
Overview
Normalized builders for failure payloads.
Defined Under Namespace
Classes: ErrorPayload
Class Method Summary collapse
- .conflict(message: "Conflict", details: nil) ⇒ Object
- .not_found(message: "Not found", details: nil) ⇒ Object
- .unauthorized(message: "Unauthorized", details: nil) ⇒ Object
- .unexpected(message: "Unexpected error", details: nil) ⇒ Object
- .validation_error(message: "Validation failed", details: nil) ⇒ Object
Class Method Details
.conflict(message: "Conflict", details: nil) ⇒ Object
37 38 39 |
# File 'lib/railsmith/errors.rb', line 37 def conflict(message: "Conflict", details: nil) ErrorPayload.new(code: :conflict, message:, details: details || {}) end |
.not_found(message: "Not found", details: nil) ⇒ Object
33 34 35 |
# File 'lib/railsmith/errors.rb', line 33 def not_found(message: "Not found", details: nil) ErrorPayload.new(code: :not_found, message:, details: details || {}) end |
.unauthorized(message: "Unauthorized", details: nil) ⇒ Object
41 42 43 |
# File 'lib/railsmith/errors.rb', line 41 def (message: "Unauthorized", details: nil) ErrorPayload.new(code: :unauthorized, message:, details: details || {}) end |
.unexpected(message: "Unexpected error", details: nil) ⇒ Object
45 46 47 |
# File 'lib/railsmith/errors.rb', line 45 def unexpected(message: "Unexpected error", details: nil) ErrorPayload.new(code: :unexpected, message:, details: details) end |
.validation_error(message: "Validation failed", details: nil) ⇒ Object
29 30 31 |
# File 'lib/railsmith/errors.rb', line 29 def validation_error(message: "Validation failed", details: nil) ErrorPayload.new(code: :validation_error, message:, details: details || {}) end |