BCUtils.Errors (bc_utils v0.11.0)
Standardized error handling for BCUtils modules.
This module provides common error types and utilities for consistent error handling across the BCUtils library.
Error Types
BCUtils.Errors.InvalidInputError
- For invalid input parametersBCUtils.Errors.ConfigurationError
- For configuration-related errorsBCUtils.Errors.TerminalError
- For terminal/display-related errorsBCUtils.Errors.ProcessError
- For process/system-related errors
Summary
Functions
Creates a formatted error report for logging or debugging.
Extracts error message from any BCUtils error struct.
Wraps a function result in an ok/error tuple if not already wrapped.
Types
Functions
Creates a formatted error report for logging or debugging.
Examples
iex> error = BCUtils.Errors.ConfigurationError.new("Invalid config", :theme, "atom", "string")
iex> BCUtils.Errors.format_error(error)
"ConfigurationError: Invalid config\nConfig Key: theme\nExpected: atom\nReceived: \"string\""
Extracts error message from any BCUtils error struct.
Examples
iex> error = BCUtils.Errors.InvalidInputError.new("Bad parameter")
iex> BCUtils.Errors.message(error)
"Bad parameter"
Wraps a function result in an ok/error tuple if not already wrapped.
Examples
iex> BCUtils.Errors.wrap_result("success")
{:ok, "success"}
iex> BCUtils.Errors.wrap_result({:error, "failed"})
{:error, "failed"}