Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/temporal/saga/concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Temporal
module Saga
module Concern
def run_saga(&block)
saga = nil
saga = Temporal::Saga::Saga.new(workflow)

block.call(saga)
Expand All @@ -14,7 +15,7 @@ def run_saga(&block)
logger.error("Saga execution aborted", { error: error.inspect })
logger.debug(error.backtrace.join("\n"))

saga.compensate
saga.compensate if saga

Result.new(false, error)
end
Expand Down
10 changes: 8 additions & 2 deletions lib/temporal/workflow/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def self.generate_error(failure, converter, default_exception_class = StandardEr
message = "#{error_type}: #{failure.message}"
exception_class = default_exception_class
end
details = failure.application_failure_info.details
begin
details = failure.application_failure_info.details
exception_or_message = converter.from_details_payloads(details)
# v1 serialization only supports StandardErrors with a single "message" argument.
# v2 serialization supports complex errors using our converters to serialize them.
Expand All @@ -34,6 +34,12 @@ def self.generate_error(failure, converter, default_exception_class = StandardEr
end
rescue StandardError => deserialization_error
message = "#{exception_class}: #{message}"
serialized_error =
if details && details.respond_to?(:payloads) && details.payloads.first && details.payloads.first.respond_to?(:data)
details.payloads.first.data
else
nil
end
exception = default_exception_class.new(message)
Temporal.logger.error(
"Could not instantiate original error. Defaulting to StandardError. Make sure the worker running " \
Expand All @@ -43,7 +49,7 @@ def self.generate_error(failure, converter, default_exception_class = StandardEr
"your error's initializer takes something other than exactly one positional argument.",
{
original_error: error_type,
serialized_error: details.payloads.first.data,
serialized_error: serialized_error,
instantiation_error_class: deserialization_error.class.to_s,
instantiation_error_message: deserialization_error.message,
},
Expand Down