Exception: Tasker::PermanentError

Inherits:
ProceduralError show all
Defined in:
lib/tasker/errors.rb

Overview

Error indicating a step failed permanently and should not be retried

Use this error when an operation fails due to permanent conditions like:

  • Invalid request data (400 status)
  • Authentication/authorization failures (401/403 status)
  • Validation errors (422 status)
  • Resource not found when it should exist (404 status in some contexts)
  • Business logic violations

Examples:

Basic permanent error

raise Tasker::PermanentError, "Invalid user ID format"

With error code for categorization

raise Tasker::PermanentError.new(
  "Insufficient funds for transaction",
  error_code: 'INSUFFICIENT_FUNDS'
)

With context for monitoring

raise Tasker::PermanentError.new(
  "User not authorized for this operation",
  error_code: 'AUTHORIZATION_FAILED',
  context: { user_id: 123, operation: 'admin_access' }
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, error_code: nil, context: {}) ⇒ PermanentError

Returns a new instance of PermanentError.

Parameters:

  • message (String)

    Error message

  • error_code (String, nil) (defaults to: nil)

    Machine-readable error code

  • context (Hash) (defaults to: {})

    Additional context for monitoring



84
85
86
87
88
# File 'lib/tasker/errors.rb', line 84

def initialize(message, error_code: nil, context: {})
  super(message)
  @error_code = error_code
  @context = context
end

Instance Attribute Details

#contextHash (readonly)

Returns Additional context for error monitoring and debugging.

Returns:

  • (Hash)

    Additional context for error monitoring and debugging



79
80
81
# File 'lib/tasker/errors.rb', line 79

def context
  @context
end

#error_codeString? (readonly)

Returns Machine-readable error code for categorization.

Returns:

  • (String, nil)

    Machine-readable error code for categorization



76
77
78
# File 'lib/tasker/errors.rb', line 76

def error_code
  @error_code
end