Class: Temporal::Workflow::Errors

Inherits:
Object
  • Object
show all
Extended by:
Concerns::Payloads
Defined in:
lib/temporal/workflow/errors.rb

Class Method Summary collapse

Methods included from Concerns::Payloads

from_details_payloads, from_payload, from_payloads, from_result_payloads, from_signal_payloads, to_details_payloads, to_payload, to_payloads, to_result_payloads, to_signal_payloads

Class Method Details

.generate_error(failure, default_exception_class = StandardError) ⇒ Object

Convert a failure returned from the server to an Error to raise to the client failure: Temporal::Api::Failure::V1::Failure



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/temporal/workflow/errors.rb', line 10

def self.generate_error(failure, default_exception_class = StandardError)
  case failure.failure_info
  when :application_failure_info
    exception_class = safe_constantize(failure.application_failure_info.type)
    exception_class ||= default_exception_class
    message = from_details_payloads(failure.application_failure_info.details)
    backtrace = failure.stack_trace.split("\n")

    exception_class.new(message).tap do |exception|
      exception.set_backtrace(backtrace) if !backtrace.empty?
    end
  when :timeout_failure_info
    TimeoutError.new("Timeout type: #{failure.timeout_failure_info.timeout_type.to_s}")
  when :canceled_failure_info
    # TODO: Distinguish between different entity cancellations
    StandardError.new(from_payloads(failure.canceled_failure_info.details))
  else
    StandardError.new(failure.message)
  end
end