error_handling

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL