ODBCErrorChain¶
Accumulates error frames from ODBC operations.
The error chain maintains a configurable history of error events, allowing inspection of what operations failed and why. It supports:
- Maximum frame limit with oldest-first eviction
- Optional auto-clear on prepare/finish operations
- Optional logging of successful operations for tracing
Configuration¶
Usage¶
// Access the most recent error
match stmt.last_error()
| let err: ODBCErrorFrame val =>
env.err.print(err.string())
end
// Iterate over all errors
for err in stmt.error_chain().values() do
env.err.print(err.operation + ": " + err.message())
end
// Print formatted chain
env.err.print(stmt.error_chain().string())
Constructors¶
create¶
Create a new error chain with default settings.
Returns¶
- ODBCErrorChain ref^
Public Functions¶
push¶
Add a frame to the chain, evicting the oldest if at capacity.
Parameters¶
- frame: ODBCErrorFrame val
Returns¶
- None val
clear¶
Clear all stored frames. Sequence counter is preserved.
Returns¶
- None val
size¶
Number of currently stored frames.
Returns¶
- USize val
values¶
Iterate over frames from oldest to newest.
Returns¶
- ArrayValues[ODBCErrorFrame val, this->Array[ODBCErrorFrame val] ref] ref^
last¶
Get the most recent error frame, or None if empty.
Returns¶
- (ODBCErrorFrame val | None val)
first¶
Get the oldest error frame, or None if empty.
Returns¶
- (ODBCErrorFrame val | None val)
apply¶
Get frame by index. Throws if out of bounds.
Parameters¶
- i: USize val
Returns¶
- ODBCErrorFrame val ?
string¶
Format the entire chain for display.
Output format:
Error chain (2 errors):
1. [stmt] prepare at main.pony:41 - OK
2. [stmt] execute at main.pony:42 - 42S02: Table 'nonexistent' doesn't exist
Returns¶
- String val
next_sequence¶
Get and increment the sequence counter.
Returns¶
- USize val
current_sequence¶
Get the current sequence counter without incrementing.
Returns¶
- USize val
set_max_frames¶
Configure maximum number of stored frames. When reduced, excess frames are evicted oldest-first.
Parameters¶
- n: USize val
Returns¶
- None val
max_frames¶
Get the current maximum frames setting.
Returns¶
- USize val
set_auto_clear¶
Configure auto-clear behavior. When true, the chain is cleared on prepare()/finish() calls.
Parameters¶
- v: Bool val
Returns¶
- None val
auto_clear¶
Get the current auto-clear setting.
Returns¶
- Bool val
set_log_success¶
Configure success logging. When true, successful operations are also recorded in the chain.
Parameters¶
- v: Bool val
Returns¶
- None val
log_success¶
Get the current log_success setting.
Returns¶
- Bool val
errors_only¶
Return only error frames (not success frames).
Returns¶
- Array[ODBCErrorFrame val] val