Exception: TezosClient::ScriptRuntimeError

Inherits:
OperationFailure show all
Defined in:
lib/tezos_client/exceptions.rb

Constant Summary collapse

FIRST_ERROR_REGEXP =
/proto.\d*-\w*\.(scriptRejectedRuntimeError|michelson_v\d\.runtime_error)/
ERROR_REGEXP =
/proto.\d*-\w*\.(scriptRejectedRuntimeError|michelson_v\d\.script_rejected)/

Constants included from Logger

Logger::FILTERED_KEYS

Instance Attribute Summary collapse

Attributes inherited from OperationFailure

#errors, #message, #metadata, #status

Instance Method Summary collapse

Methods included from Logger

#log, #tezos_contents_log, #tezos_contents_log_filter

Constructor Details

#initialize(metadata:, errors:, status:) ⇒ ScriptRuntimeError

Returns a new instance of ScriptRuntimeError.



101
102
103
104
105
106
107
108
109
110
# File 'lib/tezos_client/exceptions.rb', line 101

def initialize(metadata:, errors:, status:)
  first_error = errors[0]
  rejection_error = errors.detect { |error| error[:id].match? ERROR_REGEXP }

  @location = rejection_error[:location]
  @contract =  first_error[:contractHandle]
  @with = rejection_error[:with]
  @message = "Script runtime Error when executing #{contract}: #{with} (location: #{location})"
  super
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.



99
100
101
# File 'lib/tezos_client/exceptions.rb', line 99

def contract
  @contract
end

#locationObject (readonly)

Returns the value of attribute location.



97
98
99
# File 'lib/tezos_client/exceptions.rb', line 97

def location
  @location
end

#withObject (readonly)

Returns the value of attribute with.



98
99
100
# File 'lib/tezos_client/exceptions.rb', line 98

def with
  @with
end