errors
Package github.com/emergent-company/emergent.memory/apps/server/pkg/sdk/errors
The errors package provides structured error handling for SDK API responses.
The Error Type
Section titled “The Error Type”type Error struct { StatusCode int // HTTP status code Code string // Machine-readable error code (e.g. "not_found") Message string // Human-readable error message from the server Details map[string]interface{} // Optional structured details from the server}
func (e *Error) Error() stringAll non-2xx API responses are returned as *Error. Network errors and other infrastructure failures are returned as plain error values.
Predicate Functions
Section titled “Predicate Functions”Use these instead of type-asserting *Error directly:
func IsNotFound(err error) bool // true if StatusCode == 404func IsForbidden(err error) bool // true if StatusCode == 403func IsUnauthorized(err error) bool // true if StatusCode == 401func IsBadRequest(err error) bool // true if StatusCode == 400Each function returns false for nil or for non-*Error values, making them safe to call on any error.
ParseErrorResponse
Section titled “ParseErrorResponse”func ParseErrorResponse(resp *http.Response) errorReads the response body and returns a *Error populated with the status code and any message from the JSON body. Useful when using client.Do for raw HTTP requests.
import sdkerrors "github.com/emergent-company/emergent.memory/apps/server/pkg/sdk/errors"
obj, err := client.Graph.GetObject(ctx, id)if err != nil { switch { case sdkerrors.IsNotFound(err): // handle 404 case sdkerrors.IsForbidden(err): // handle 403 case sdkerrors.IsUnauthorized(err): // handle 401 case sdkerrors.IsBadRequest(err): // handle 400 default: // network error or unexpected } return}