SuperWorker.Supervisor.ErrorHandler exception (SuperWorker v0.3.6)

View Source

Provides consistent error handling for the SuperWorker system.

This module defines a custom exception and helper functions to create standardized error tuples. This ensures that errors are handled uniformly across the application, making the system more robust and easier to debug.

Summary

Functions

Creates a standardized already exists error.

Creates a standardized "already running" error.

Creates a standardized API timeout error.

Creates a standardized invalid config error.

Creates a standardized invalid options error.

Callback implementation for Exception.message/1.

Creates a standardized not found error.

Creates a standardized "not running" error.

Types

error_reason()

@type error_reason() ::
  :not_found
  | :already_exists
  | :already_running
  | :not_running
  | :api_timeout
  | :invalid_type
  | :worker_not_found
  | :group_not_found
  | :chain_not_found
  | :supervisor_not_found
  | :worker_already_exists
  | :group_already_exists
  | :chain_already_exists
  | :supervisor_already_exists
  | {:invalid_options, term()}
  | {:invalid_config, term()}
  | {:custom, term()}

error_tuple()

@type error_tuple() :: {:error, error_reason()}

Functions

already_exists(type \\ :generic)

@spec already_exists(atom()) :: error_tuple()

Creates a standardized already exists error.

already_running()

@spec already_running() :: error_tuple()

Creates a standardized "already running" error.

api_timeout()

@spec api_timeout() :: error_tuple()

Creates a standardized API timeout error.

invalid_config(details)

@spec invalid_config(term()) :: error_tuple()

Creates a standardized invalid config error.

invalid_options(details)

@spec invalid_options(term()) :: error_tuple()

Creates a standardized invalid options error.

log_error(module, message, context \\ [])

@spec log_error(module(), String.t(), keyword()) :: :ok

Logs an error message.

message(map)

Callback implementation for Exception.message/1.

not_found(type \\ :generic)

@spec not_found(atom()) :: error_tuple()

Creates a standardized not found error.

not_running()

@spec not_running() :: error_tuple()

Creates a standardized "not running" error.

raise_error(reason)

@spec raise_error(term()) :: no_return()

Raises a SuperWorker.Error exception.