{"modulePath":"github.com/stacklok/toolhive","version":"v0.77.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\nPackage errors provides HTTP error handling utilities for the API.\n\n## Functions\n\n```go\nfunc ErrorHandler(fn HandlerWithError) http.HandlerFunc\n```\nErrorHandler wraps a HandlerWithError and converts returned errors into appropriate HTTP responses.\n\nThe decorator:\n\n  - Returns early if no error is returned (handler already wrote response)\n  - Extracts HTTP status code from the error using errors.Code()\n  - For 5xx errors: logs full error details, returns generic message to client\n  - For 4xx errors: returns error message to client\n\nUsage:\n\n\tr.Get(\"/{name}\", apierrors.ErrorHandler(routes.getWorkload))\n\n## Types\n\n```go\ntype HandlerWithError func(http.ResponseWriter, *http.Request) error\n```\nHandlerWithError is an HTTP handler that can return an error. This signature allows handlers to return errors instead of manually writing error responses, enabling centralized error handling.\n\n","path":"github.com/stacklok/toolhive/pkg/api/errors","name":"errors","synopsis":"Package errors provides HTTP error handling utilities for the API.","isRedistributable":true}
