Class: Woods::Operator::ErrorEscalator

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/operator/error_escalator.rb

Overview

Classifies pipeline errors by severity and suggests remediation.

Examples:

escalator = ErrorEscalator.new
result = escalator.classify(Timeout::Error.new("connection timed out"))
result[:severity]     # => :transient
result[:remediation]  # => "Retry after a short delay"

Constant Summary collapse

TRANSIENT_PATTERNS =
[
  { class_pattern: /Timeout|ETIMEDOUT/, category: 'timeout', remediation: 'Retry after a short delay' },
  { class_pattern: /Net::/, category: 'network', remediation: 'Check network connectivity and retry' },
  { class_pattern: /RateLimited|429/, category: 'rate_limit',
    remediation: 'Back off and retry with exponential delay' },
  { class_pattern: /CircuitOpenError/, category: 'circuit_open',
    remediation: 'Wait for circuit breaker reset timeout' },
  { class_pattern: /ConnectionPool|Busy/, category: 'resource_contention',
    remediation: 'Wait for resources to free up' }
].freeze
PERMANENT_PATTERNS =
[
  { class_pattern: /NameError|NoMethodError/, category: 'code_error',
    remediation: 'Fix the code error and re-extract' },
  { class_pattern: /Errno::ENOENT|FileNotFoundError/, category: 'missing_file',
    remediation: 'Verify file paths and re-run extraction' },
  { class_pattern: /JSON::ParserError/, category: 'corrupt_data',
    remediation: 'Clean index and re-extract' },
  { class_pattern: /ConfigurationError/, category: 'configuration',
    remediation: 'Review Woods configuration' },
  { class_pattern: /ExtractionError/, category: 'extraction_failure',
    remediation: 'Check extraction logs for specific failure details' }
].freeze

Instance Method Summary collapse

Instance Method Details

#classify(error) ⇒ Hash

Classify an error by severity and suggest remediation.

Parameters:

  • error (StandardError)

    The error to classify

Returns:

  • (Hash)

    :severity (:transient or :permanent), :category, :remediation, :error_class, :message



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/woods/operator/error_escalator.rb', line 42

def classify(error)
  error_string = "#{error.class} #{error.message}"

  match = find_match(error_string, TRANSIENT_PATTERNS, :transient) ||
          find_match(error_string, PERMANENT_PATTERNS, :permanent)

  if match
    match.merge(error_class: error.class.name, message: error.message)
  else
    {
      severity: :unknown,
      category: 'unclassified',
      remediation: 'Investigate error details and check logs',
      error_class: error.class.name,
      message: error.message
    }
  end
end