Documentation
¶
Overview ¶
Demonstrates the typed errors opencodesdk surfaces and how to branch on them with errors.Is / errors.As.
The SDK exposes:
- Sentinel errors (ErrCLINotFound, ErrUnsupportedCLIVersion, ErrAuthRequired, ErrCancelled, ErrClientClosed, ErrClientNotStarted, ErrClientAlreadyConnected, ErrRequestTimeout, ErrTransport)
- Typed errors (*RequestError, *CLINotFoundError, *ProcessError, *TransportError) that all satisfy the OpencodeSDKError marker interface so callers can distinguish SDK-originated errors from arbitrary Go errors in the same code path.
This example trips each sentinel case deliberately so you can see the shape of the resulting error.
go run ./examples/error_handling
Click to show internal directories.
Click to hide internal directories.