Class: Errorio::Details
- Inherits:
-
Object
- Object
- Errorio::Details
- Defined in:
- lib/errorio/details.rb
Overview
Some helpers
Class Method Summary collapse
-
.by_code(code, args = {}) ⇒ Hash
Error details by code:.
-
.t_msg(code, args = {}) ⇒ String
Interpolate error message from i18n.
Class Method Details
.by_code(code, args = {}) ⇒ Hash
Error details by code:
errors.add :base, :invalid, Errorio.by_code(:E0001, user_id: 129)
> {
code: :E0001,
message: "Invitation from user with ID 1823 was expired"
invited_by: 1823
}
28 29 30 31 32 33 34 |
# File 'lib/errorio/details.rb', line 28 def self.by_code(code, args = {}) msg = t_msg(code, args) { code: code, message: msg }.merge(args) end |
.t_msg(code, args = {}) ⇒ String
Interpolate error message from i18n
11 12 13 |
# File 'lib/errorio/details.rb', line 11 def self.t_msg(code, args = {}) I18n.t("errorio.messages.#{code}", **args) end |