go/error_example_test.go
Snider 48a9bd6606 fix: dogfood Core primitives in tests — eliminate errors import
Replaced all errors.New() with core.NewError() and errors.Is() with
core.Is() across error_test.go, error_example_test.go, utils_test.go.

The "errors" stdlib import is now zero across all test files.
Examples teach agents core.NewError() and core.Is() — not errors.New().

Dogfooding: Core's own tests use Core's own primitives.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 18:49:55 +00:00

34 lines
656 B
Go

package core_test
import (
"fmt"
. "dappco.re/go/core"
)
func ExampleE() {
err := E("cache.Get", "key not found", nil)
fmt.Println(Operation(err))
fmt.Println(ErrorMessage(err))
// Output:
// cache.Get
// key not found
}
func ExampleWrap() {
cause := NewError("connection refused")
err := Wrap(cause, "database.Connect", "failed to reach host")
fmt.Println(Operation(err))
fmt.Println(Is(err, cause))
// Output:
// database.Connect
// true
}
func ExampleRoot() {
cause := NewError("original")
wrapped := Wrap(cause, "op1", "first wrap")
double := Wrap(wrapped, "op2", "second wrap")
fmt.Println(Root(double))
// Output: original
}