Class: Kobako::Outcome::Panic

Inherits:
Object
  • Object
show all
Defined in:
lib/kobako/outcome/panic.rb,
sig/kobako/outcome/panic.rbs

Overview

Wire-contract Outcome Envelope → Panic envelope (docs/wire-contract.md Outcome Envelope). Wire-shaped failure record carried in the OUTCOME_BUFFER when the guest run terminates with an uncaught top-level exception.

This is the wire data, not a raisable Ruby exception. The mapping from Panic to a three-layer Ruby exception (TrapError / SandboxError / ServiceError) happens at Kobako::Outcome.decode via build_panic_error — callers never raise Panic directly.

The five fields mirror SPEC: origin ("sandbox" / "service"), klass (the guest-side exception class name as a String), message, backtrace (Array of String), details (any wire-legal value, nil when absent). Required-field validation is enforced at construction; the ORIGIN_SANDBOX / ORIGIN_SERVICE constants pin the two SPEC-defined origin values.

Built on the class X < Data.define(...) subclass form so the class body is fully Steep-visible; ruby/rbs upstream documents this as the Steep-friendly shape and the Style/DataInheritance cop is disabled on that basis (see .rubocop.yml).

Constant Summary collapse

ORIGIN_SANDBOX =

Returns:

  • (String)
"sandbox"
ORIGIN_SERVICE =

Returns:

  • (String)
"service"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin:, klass:, message:, backtrace: [], details: nil) ⇒ Panic

Returns a new instance of Panic.

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
# File 'lib/kobako/outcome/panic.rb', line 30

def initialize(origin:, klass:, message:, backtrace: [], details: nil)
  raise ArgumentError, "Panic origin must be String"  unless origin.is_a?(String)
  raise ArgumentError, "Panic class must be String"   unless klass.is_a?(String)
  raise ArgumentError, "Panic message must be String" unless message.is_a?(String)
  unless backtrace.is_a?(Array) && backtrace.all?(String)
    raise ArgumentError, "Panic backtrace must be Array of String"
  end

  super
end

Instance Attribute Details

#backtraceArray[String] (readonly)

Returns the value of attribute backtrace.

Returns:

  • (Array[String])


10
11
12
# File 'sig/kobako/outcome/panic.rbs', line 10

def backtrace
  @backtrace
end

#detailsObject (readonly)

Returns the value of attribute details.

Returns:

  • (Object)


11
12
13
# File 'sig/kobako/outcome/panic.rbs', line 11

def details
  @details
end

#klassString (readonly)

Returns the value of attribute klass.

Returns:

  • (String)


8
9
10
# File 'sig/kobako/outcome/panic.rbs', line 8

def klass
  @klass
end

#messageString (readonly)

Returns the value of attribute message.

Returns:

  • (String)


9
10
11
# File 'sig/kobako/outcome/panic.rbs', line 9

def message
  @message
end

#originString (readonly)

Returns the value of attribute origin.

Returns:

  • (String)


7
8
9
# File 'sig/kobako/outcome/panic.rbs', line 7

def origin
  @origin
end

Instance Method Details

#==Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


29
# File 'sig/kobako/outcome/panic.rbs', line 29

def ==: (untyped other) -> bool

#hashInteger

Returns:

  • (Integer)


31
# File 'sig/kobako/outcome/panic.rbs', line 31

def hash: () -> Integer

#withObject



21
# File 'sig/kobako/outcome/panic.rbs', line 21

def with: (