Predicator.Errors (predicator v2.2.0)
View SourceCommon utilities for error formatting across all Predicator error modules.
This module provides shared functions for formatting error messages, type names, and operation names consistently across all error types.
Summary
Functions
Formats an expected type name for error messages with proper articles.
Formats an operation name for user-friendly error messages.
Formats a type name with its value for error messages.
Functions
Formats an expected type name for error messages with proper articles.
Examples
iex> Predicator.Errors.expected_type_name(:integer)
"an integer"
iex> Predicator.Errors.expected_type_name(:boolean)
"a boolean"
iex> Predicator.Errors.expected_type_name(:custom_type)
"a custom_type"
Formats an operation name for user-friendly error messages.
Examples
iex> Predicator.Errors.operation_display_name(:add)
"Arithmetic add"
iex> Predicator.Errors.operation_display_name(:logical_and)
"Logical AND"
iex> Predicator.Errors.operation_display_name(:unary_bang)
"Logical NOT"
Formats a type name with its value for error messages.
Examples
iex> Predicator.Errors.type_name_with_value(:string, "hello")
"\"hello\" (string)"
iex> Predicator.Errors.type_name_with_value(:integer, 42)
"42 (integer)"
iex> Predicator.Errors.type_name_with_value(:undefined, :undefined)
":undefined (undefined)"