Class: Fusion::Interpreter::ErrorVal
- Inherits:
-
Object
- Object
- Fusion::Interpreter::ErrorVal
- Defined in:
- lib/fusion/interpreter/error_val.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Class Method Summary collapse
-
.internal(kind:, location:, operation:, input:, message: nil) ⇒ Object
Build an interpreter-produced error with the standardized payload shape documented in docs/user/reference.md §6.5.
Instance Method Summary collapse
-
#initialize(payload) ⇒ ErrorVal
constructor
A new instance of ErrorVal.
- #inspect ⇒ Object
-
#internal_error? ⇒ Boolean
Whether this is an interpreter-produced error (vs. a user-constructed ‘!expr`).
- #to_s ⇒ Object
Constructor Details
#initialize(payload) ⇒ ErrorVal
Returns a new instance of ErrorVal.
12 13 14 15 |
# File 'lib/fusion/interpreter/error_val.rb', line 12 def initialize(payload) @payload = payload @internal = false end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
10 11 12 |
# File 'lib/fusion/interpreter/error_val.rb', line 10 def payload @payload end |
Class Method Details
.internal(kind:, location:, operation:, input:, message: nil) ⇒ Object
Build an interpreter-produced error with the standardized payload shape documented in docs/user/reference.md §6.5.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fusion/interpreter/error_val.rb', line 25 def self.internal(kind:, location:, operation:, input:, message: nil) error = new( "kind" => kind, "location" => location, "operation" => operation, "input" => input, **( ? { "message" => } : {}) ) # Mark as "@internal" to activate lenient serialization. error.instance_variable_set(:@internal, true) error end |
Instance Method Details
#inspect ⇒ Object
40 41 42 |
# File 'lib/fusion/interpreter/error_val.rb', line 40 def inspect "!#{payload.inspect}" end |
#internal_error? ⇒ Boolean
Whether this is an interpreter-produced error (vs. a user-constructed ‘!expr`). Governs serialization — see docs/user/reference.md §9.3.
19 20 21 |
# File 'lib/fusion/interpreter/error_val.rb', line 19 def internal_error? @internal end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/fusion/interpreter/error_val.rb', line 44 def to_s inspect end |