This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Run all tests
go test ./...
# Run a single test
go test -run TestMarshalUnmarshalPropagatedError .
# Regenerate code after modifying InternalState constants or PropagatedError/ErrorSource structs
go generate ./...This is a single-package Go library (github.com/redsift/go-errs, package errs) that provides a structured error type for use across redsift services.
PropagatedError (defined in errors.go) is the central error type. It carries:
Id— a unique error instance ID (generated viagithub.com/redsift/go-foodfans)Code— anInternalStateenum value identifying the error categoryTitle,Detail,Link,Source— human-readable and structured contextStatus— HTTP status code (not serialized)cause— unexported wrapped error (accessible viaUnwrap())
InternalState (defined in lookups.go) is an iota-based int enum of error codes. Each constant is a coffee-drink name (e.g. Espresso, Latte, Cappuccino). These values are stable integers used in serialization — order matters, never reorder or remove existing constants.
Several files are auto-generated and must not be edited manually:
errors_gen.go/errors_gen_test.go— msgpack serialization forPropagatedErrorandErrorSource(generated bymsgp)lookups_gen.go/lookups_gen_test.go— msgpack serialization forInternalStateinternalstate_string.go—String()method forInternalState(generated bystringer)internalstate_jsonenums.go— JSON marshal/unmarshal forInternalState(generated byjsonenums)
Run go generate ./... after any change to InternalState constants or the PropagatedError/ErrorSource struct fields tagged with msg:.
WrapWithCode(code, err)— wraps an existing error as aPropagatedErrorwith a specificInternalStateWrap(err)— wraps usingUnknowncodeWrapAsParameterError,WrapAsConfigIssue,WrapAsAssert— convenience wrappers for common codesRetryWithIncrementAndFlag(err)— inspects aPropagatedErrorto determine retry behavior; specific codes (Turkish,Mocha,Guillermo,Espresso,Kopitubruk,Macchiato) have defined retry semanticsIsCode(err, code)— checks if an error has a specificInternalStateErrorf(format, args...)— likefmt.Errorfbut propagatesPropagatedErroridentity when an error arg is a*PropagatedErrorPostProcessJsonError(data, err)— enriches JSON parse errors with source location contextNotYetImplemented(feature)— returns a lightweightnyiError(not aPropagatedError)