Exception: Taski::TaskError

Inherits:
StandardError
  • Object
show all
Extended by:
AggregateAware
Defined in:
lib/taski.rb

Overview

Base class for task-specific error wrappers. Each Task subclass automatically gets a ::Error class that inherits from this. This allows rescuing errors by task class: rescue MyTask::Error => e

Examples:

Rescuing task-specific errors

begin
  MyTask.value
rescue MyTask::Error => e
  puts "MyTask failed: #{e.message}"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AggregateAware

===

Constructor Details

#initialize(cause, task_class:) ⇒ TaskError

Returns a new instance of TaskError.

Parameters:

  • cause (Exception)

    The original error

  • task_class (Class)

    The task class where the error occurred



112
113
114
115
116
117
# File 'lib/taski.rb', line 112

def initialize(cause, task_class:)
  @cause = cause
  @task_class = task_class
  super(cause.message)
  set_backtrace(cause.backtrace)
end

Instance Attribute Details

#causeException (readonly)

Returns The original error that occurred in the task.

Returns:

  • (Exception)

    The original error that occurred in the task



105
106
107
# File 'lib/taski.rb', line 105

def cause
  @cause
end

#task_classClass (readonly)

Returns The task class where the error occurred.

Returns:

  • (Class)

    The task class where the error occurred



108
109
110
# File 'lib/taski.rb', line 108

def task_class
  @task_class
end