Exception: RailsFlowMap::Error
- Inherits:
-
StandardError
- Object
- StandardError
- RailsFlowMap::Error
- Defined in:
- lib/rails_flow_map/errors.rb
Overview
Base error class for all RailsFlowMap errors
This class provides a common interface for all errors raised by the RailsFlowMap gem, including error categorization, context preservation, and structured error reporting.
Direct Known Subclasses
ConfigurationError, FileOperationError, FormatterError, GraphParseError, GraphValidationError, InvalidInputError, NotImplementedError, ResourceLimitError, SecurityError
Instance Attribute Summary collapse
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
Instance Method Summary collapse
-
#initialize(message, context: {}, error_code: nil, category: :general) ⇒ Error
constructor
Initialize a new error with context and categorization.
-
#to_h ⇒ Hash
Full error information including context.
-
#to_json(*args) ⇒ String
JSON representation of the error.
Constructor Details
#initialize(message, context: {}, error_code: nil, category: :general) ⇒ Error
Initialize a new error with context and categorization
18 19 20 21 22 23 |
# File 'lib/rails_flow_map/errors.rb', line 18 def initialize(, context: {}, error_code: nil, category: :general) super() @context = context @error_code = error_code || self.class.name.split('::').last.downcase @category = category end |
Instance Attribute Details
#category ⇒ Object (readonly)
Returns the value of attribute category.
10 11 12 |
# File 'lib/rails_flow_map/errors.rb', line 10 def category @category end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/rails_flow_map/errors.rb', line 10 def context @context end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
10 11 12 |
# File 'lib/rails_flow_map/errors.rb', line 10 def error_code @error_code end |
Instance Method Details
#to_h ⇒ Hash
Returns Full error information including context.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rails_flow_map/errors.rb', line 26 def to_h { error_class: self.class.name, message: , error_code: error_code, category: category, context: context, backtrace: backtrace&.first(10) } end |
#to_json(*args) ⇒ String
Returns JSON representation of the error.
38 39 40 41 |
# File 'lib/rails_flow_map/errors.rb', line 38 def to_json(*args) require 'json' to_h.to_json(*args) end |