Documentation
¶
Overview ¶
Package on_error provides the `@on_error { when ... -> target; else -> target }` block. On a runtime error, WrapPipeline wraps the compiled program with a CatchAny handler that evaluates each rule's condition against the error and routes to the matching target.
Typical use:
@on_error {
when error.kind == "Timeout" -> cov.recoverable
when error.kind == "NotFound" -> log.info
else -> error.info
}
Index ¶
Constants ¶
View Source
const ID = "on_error"
Variables ¶
View Source
var Directive = core.Directive{
Name: "on_error",
Example: `@on_error {
when error.kind == "Timeout" -> cov.recoverable
else -> noop
}`,
Handler: handleDirective,
}
Directive parses the `@on_error { ... }` block and writes it to meta["on_error"].
View Source
var ErrorInfoAction = action.New("error.info", func(ctx context.Context, _ any) (map[string]any, error) { recovered, ok := contracts.RecoveredErrorFrom(ctx) if !ok || recovered == nil { return nil, xerr.NotFound("no recovered error in context") } return map[string]any{ "kind": recovered.Kind, "message": recovered.Err.Error(), }, nil }). Description("Return information about the recovered error"). Tag("error", "recovery"). Build()
ErrorInfoAction reads the recovered error from the context and returns it as a map. It is the default target for rules that want to inspect the original error without further processing.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.