lib/jflow/activity/task.rb in jflow-0.3.6 vs lib/jflow/activity/task.rb in jflow-0.4.0

- old
+ new

@@ -41,10 +41,16 @@ @klass_value ||= JFlow.configuration.activity_map.klass_for(name,version) raise "Could not find code to run for given activity" unless @klass_value @klass_value end + def definition_options + @definition_options ||= JFlow.configuration.activity_map.options_for(name,version) + raise "Could not find activity definition for #{name}, #{version}" unless @definition_options + @definition_options + end + def method if name.split('.').size > 1 method = name.split('.').last else method = "process" @@ -65,28 +71,32 @@ task_token: token, result: result, }) end - def failed!(exception) log "Task Failed #{exception.message}" reason = truncate(exception.message, MAX_REASON_SIZE) - details = if exception.backtrace - truncate(exception.backtrace.join("\n"), MAX_DETAILS_SIZE) - else - "no stacktrace" - end + if retryable?(exception) + converted_exception = JFlow::Exceptions::Common.new(exception) + else + converted_exception = JFlow::Exceptions::Fatal.new(exception) + end + swf_client.respond_activity_task_failed( task_token: token, reason: reason, - details: details + details: truncate(YAML.dump_stream(converted_exception, exception.backtrace), MAX_DETAILS_SIZE) ) end private + + def retryable?(exception) + !definition_options[:exceptions_to_exclude].include?(exception.class) + end def truncate(message, max_length) return message unless message.length > max_length tail_room = max_length - TRUNCATION_IDENTIFIER.length