Pipeline.Error.NestedPipeline (pipeline v0.0.1)

View Source

Enhanced error formatting and context tracking for nested pipeline execution.

Provides comprehensive error messages with full execution stack traces, pipeline hierarchy, and relevant context information for debugging nested pipeline failures.

Summary

Functions

Create a structured error log entry for debugging.

Format a circular dependency error with the detected cycle.

Format a nested pipeline error with comprehensive context information.

Format a resource limit error with current usage information.

Format a timeout error with execution context.

Types

debug_log_entry()

@type debug_log_entry() :: %{
  timestamp: DateTime.t(),
  error_type: error_type(),
  error_message: String.t(),
  pipeline_id: String.t(),
  nesting_depth: non_neg_integer(),
  step_name: String.t() | nil,
  step_type: String.t() | nil,
  execution_chain: [String.t(), ...],
  total_steps: non_neg_integer(),
  elapsed_ms: integer(),
  context_summary: %{
    context_size: non_neg_integer(),
    has_parent: boolean(),
    key_count: non_neg_integer(),
    nesting_depth: non_neg_integer()
  },
  step_config: map() | nil
}

error_context()

@type error_context() :: %{
  pipeline_id: String.t(),
  step_name: String.t() | nil,
  nesting_depth: non_neg_integer(),
  execution_chain: [String.t()],
  start_time: DateTime.t(),
  elapsed_ms: non_neg_integer(),
  total_steps: non_neg_integer(),
  step_index: non_neg_integer() | nil,
  parent_context: error_context() | nil
}

error_type()

@type error_type() ::
  :circular_dependency
  | :not_found
  | :resource_limit
  | :timeout
  | :unknown
  | :validation

formatted_error()

@type formatted_error() :: %{
  message: String.t(),
  context: error_context(),
  stack_trace: [String.t()],
  hierarchy: String.t(),
  debug_info: map()
}

Functions

create_debug_log_entry(error, context)

@spec create_debug_log_entry(any(), map()) :: debug_log_entry()

Create a structured error log entry for debugging.

Parameters

  • error: The error that occurred
  • context: Current execution context
  • step: Current step configuration (optional)

Returns

  • Structured log entry map

create_debug_log_entry(error, context, step)

@spec create_debug_log_entry(any(), map(), map() | nil) :: debug_log_entry()

extract_base_error_message(error)

format_circular_dependency_error(circular_chain, context)

@spec format_circular_dependency_error([String.t()], map()) :: String.t()

Format a circular dependency error with the detected cycle.

Parameters

  • circular_chain: List of pipeline IDs forming the circular dependency
  • context: Current execution context

Returns

  • Formatted circular dependency error message

format_nested_error(error, context, step \\ nil)

@spec format_nested_error(any(), map(), map() | nil) :: formatted_error()

Format a nested pipeline error with comprehensive context information.

Parameters

  • error: The original error (string, exception, or error tuple)
  • context: Current execution context
  • step: Current step configuration (optional)

Returns

  • Formatted error with full context information

Examples

iex> context = %{nesting_depth: 1, pipeline_id: "child", parent_context: %{pipeline_id: "parent", nesting_depth: 0}}
iex> formatted = Pipeline.Error.NestedPipeline.format_nested_error("API timeout", context)
iex> String.contains?(formatted.message, "parent → child")
true

format_resource_limit_error(limit_type, current_value, limit_value, context)

@spec format_resource_limit_error(atom(), any(), any(), map()) :: String.t()

Format a resource limit error with current usage information.

Parameters

  • limit_type: Type of limit exceeded (:memory, :depth, :steps)
  • current_value: Current resource usage
  • limit_value: The limit that was exceeded
  • context: Current execution context

Returns

  • Formatted resource limit error message

format_timeout_error(timeout_seconds, context, elapsed_ms)

@spec format_timeout_error(non_neg_integer(), map(), non_neg_integer()) :: String.t()

Format a timeout error with execution context.

Parameters

  • timeout_seconds: The timeout that was exceeded
  • context: Current execution context
  • elapsed_ms: Actual elapsed time in milliseconds

Returns

  • Formatted timeout error message