Structured error handling for clj-ebpf.
Provides:
Structured error handling for clj-ebpf. Provides: - Typed exception hierarchy for BPF operations - Automatic retry for transient errors - Rich error context and diagnostics
Default maximum number of retries for transient errors
Default maximum number of retries for transient errors
Multiplier for exponential backoff
Multiplier for exponential backoff
Default delay between retries in milliseconds
Default delay between retries in milliseconds
(arch-error message data)Create an architecture/platform error.
Create an architecture/platform error.
(assert-map-fd fd context)Assert that a map file descriptor is valid.
Assert that a map file descriptor is valid.
(assert-program-fd fd context)Assert that a program file descriptor is valid.
Assert that a program file descriptor is valid.
(attachment-error message data)Create an attachment error.
Create an attachment error.
(bpf-error error-type message data)Create a BPF exception with structured data.
Arguments:
Returns an ExceptionInfo with :error-type key.
Create a BPF exception with structured data. Arguments: - error-type: One of the error-types keywords - message: Human-readable error message - data: Map of additional context Returns an ExceptionInfo with :error-type key.
(check-result result operation get-errno-fn errno->kw-fn)Check a syscall result and throw an appropriate error if negative.
Arguments:
Returns result if non-negative, throws otherwise.
Check a syscall result and throw an appropriate error if negative. Arguments: - result: The syscall result (typically an int or long) - operation: String describing the operation - get-errno-fn: Zero-arg function to get current errno - errno->kw-fn: Function to convert errno to keyword Returns result if non-negative, throws otherwise.
(classify-syscall-error operation errno errno-kw)(classify-syscall-error operation errno errno-kw additional-data)Create a typed error from a syscall failure.
Arguments:
Returns an ExceptionInfo with appropriate error type.
Create a typed error from a syscall failure. Arguments: - operation: String describing the operation (e.g., "map-create") - errno: The errno number - errno-kw: The errno keyword - additional-data: Optional additional context Returns an ExceptionInfo with appropriate error type.
(enhance-error e additional-data)Enhance an exception with additional context.
Arguments:
Returns a new exception with merged data.
Enhance an exception with additional context. Arguments: - e: The original exception - additional-data: Map of additional context to merge Returns a new exception with merged data.
(errno->error-type errno-kw)Map an errno keyword to the most appropriate error type.
Map an errno keyword to the most appropriate error type.
(error-summary e)Get a one-line summary of an exception.
Get a one-line summary of an exception.
(format-error e)Format an exception for display.
Returns a multi-line string with error details.
Format an exception for display. Returns a multi-line string with error details.
(map-error message data)Create a map operation error.
Create a map operation error.
Errno values that indicate permission issues
Errno values that indicate permission issues
(permission-error message data)Create a permission error.
Create a permission error.
(permission-error? e)Returns true if the exception represents a permission error.
Returns true if the exception represents a permission error.
(program-error message data)Create a program operation error.
Create a program operation error.
Errno values that indicate resource exhaustion
Errno values that indicate resource exhaustion
(resource-error message data)Create a resource exhaustion error.
Create a resource exhaustion error.
(resource-error? e)Returns true if the exception represents a resource exhaustion error.
Returns true if the exception represents a resource exhaustion error.
(retrying opts & body)Macro form of with-retry for more convenient usage.
Example: (retrying {:max-retries 5} (syscall/map-create ...))
Macro form of with-retry for more convenient usage.
Example:
(retrying {:max-retries 5}
(syscall/map-create ...))(syscall-error message data)Create a syscall error.
Create a syscall error.
Errno values that indicate transient failures worth retrying
Errno values that indicate transient failures worth retrying
(transient-error? e)Returns true if the exception represents a transient error worth retrying.
Returns true if the exception represents a transient error worth retrying.
(verifier-error message data)Create a verifier rejection error.
Create a verifier rejection error.
(verifier-error? e)Returns true if the exception is a BPF verifier rejection.
Returns true if the exception is a BPF verifier rejection.
(with-retry f)(with-retry f
{:keys [max-retries delay-ms backoff-factor on-retry]
:or {max-retries *max-retries*
delay-ms *retry-delay-ms*
backoff-factor *retry-backoff-factor*
on-retry (fn [_ _ _] nil)}})Execute a function with automatic retry on transient errors.
Arguments:
Returns the result of f, or throws after max retries.
Execute a function with automatic retry on transient errors. Arguments: - f: Zero-argument function to execute - opts: Optional map with: - :max-retries (default 3) - :delay-ms (default 100) - :backoff-factor (default 2.0) - :on-retry (fn [attempt delay-ms exception] ...) - callback on retry Returns the result of f, or throws after max retries.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |