StaticassertThrow a CmpStrUsageError if a condition is not met.
The condition to assert
The error message to throw if the condition is false
Optionalmeta: CmpStrErrorMetaOptional structured metadata for the error
StaticformatFormat any error into a readable string.
The error to format
StaticrethrowWrap an unknown error into a CmpStrInternalError.
The error to wrap
The error message to use for the wrapped error
Optionalmeta: CmpStrErrorMetaOptional structured metadata for the error
StaticwrapExecute a synchronous operation and wrap any exception as a CmpStrInternalError.
This is used to avoid repeating try/catch blocks and to add consistent context
to unexpected failures while preserving the original error as cause.
The function to execute
The error message to use if an exception is thrown
Optionalmeta: CmpStrErrorMetaOptional structured metadata for the error
The result of the function if it executes successfully
StaticwrapExecute an asynchronous operation and wrap any exception as a CmpStrInternalError.
The asynchronous function to execute
The error message to use if an exception is thrown
Optionalmeta: CmpStrErrorMetaOptional structured metadata for the error
A promise that resolves to the result of the function if it executes successfully
Helper utilities for throwing and formatting errors.
Provides methods for asserting conditions, wrapping unknown errors, and formatting errors into readable strings. This centralizes error handling logic and ensures consistent error messages across the codebase.