Exception: Card::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Card::Error
- Defined in:
- lib/card/error.rb
Overview
exceptions and errors. (arguably most of these should be Card::Exception)
Direct Known Subclasses
Defined Under Namespace
Classes: Abort, BadQuery, CodenameNotFound, EditConflict, NotFound, PermissionDenied, ServerError, UserError
Constant Summary collapse
- KEY_MAP =
{ permission_denied: PermissionDenied, conflict: EditConflict }.freeze
Instance Attribute Summary collapse
-
#card ⇒ Object
Returns the value of attribute card.
Class Method Summary collapse
- .card_error_class(exception, card) ⇒ Object
- .cardify_exception(exception, card) ⇒ Object
- .invalid_card_error_class(card) ⇒ Object
Instance Method Summary collapse
- #card_message_text ⇒ Object
-
#initialize(message = nil) ⇒ Error
constructor
A new instance of Error.
- #message_from_card ⇒ Object
- #report ⇒ Object
Constructor Details
Instance Attribute Details
#card ⇒ Object
Returns the value of attribute card.
13 14 15 |
# File 'lib/card/error.rb', line 13 def card @card end |
Class Method Details
.card_error_class(exception, card) ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/card/error.rb', line 103 def card_error_class exception, card case exception when ActiveRecord::RecordInvalid invalid_card_error_class card when ActiveRecord::RecordNotFound, ActionController::MissingFile Card::Error::NotFound else Card::Error::ServerError end end |
Instance Method Details
#card_message_text ⇒ Object
32 33 34 |
# File 'lib/card/error.rb', line 32 def card.errors.first&. end |
#message_from_card ⇒ Object
23 24 25 26 |
# File 'lib/card/error.rb', line 23 def I18n.t :exception_for_card, scope: %i[lib card error], cardname: card.name, message: end |
#report ⇒ Object
28 29 30 |
# File 'lib/card/error.rb', line 28 def report Rails.logger.info "exception = #{self.class}: #{}" end |