Exception: Gel::UserError
- Inherits:
-
StandardError
- Object
- StandardError
- Gel::UserError
- Includes:
- ReportableError
- Defined in:
- lib/gel/error.rb
Overview
Base class for user-facing errors. Errors can directly include ReportableError to bypass this, but absent a specific reason, they should subclass UserError.
Prefer narrow-purpose error classes that receive context parameters over raising generic classes with pre-rendered message parameters. The former can do a better job of fully describing the problem when producing detailed CLI output, without filling real code with long message heredocs.
Define all UserError subclasses in this file. (Non-reportable errors, which describe errors in interaction between internal components, can and should be defined whereever they’re used.)
Direct Known Subclasses
Error::BrokenStubError, Error::CannotActivateError, Error::ExtensionBuildError, Error::GemfileEvaluationError, Error::MismatchRubyEngineError, Error::MismatchRubyVersionError, Error::NoGemfile, Error::NoVersionSatisfy, Error::ParsedGemspecError, Error::TooManyRedirectsError, Error::UnexpectedConfigError, Error::UnknownCommandError, Error::UnknownGemError
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(**context) ⇒ UserError
constructor
A new instance of UserError.
- #inner_backtrace ⇒ Object
- #message ⇒ Object
Methods included from ReportableError
Constructor Details
#initialize(**context) ⇒ UserError
Returns a new instance of UserError.
47 48 49 50 51 |
# File 'lib/gel/error.rb', line 47 def initialize(**context) @context = context super end |
Instance Method Details
#[](key) ⇒ Object
53 54 55 |
# File 'lib/gel/error.rb', line 53 def [](key) @context.fetch(key) end |
#inner_backtrace ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gel/error.rb', line 61 def inner_backtrace return [] unless cause bt = cause.backtrace_locations ignored_bt = backtrace_locations while bt.last.to_s == ignored_bt.last.to_s bt.pop ignored_bt.pop end while bt.last.path == ignored_bt.last.path bt.pop end bt end |
#message ⇒ Object
57 58 59 |
# File 'lib/gel/error.rb', line 57 def self.class.name end |