{"modulePath":"github.com/aserto-dev/errors","version":"v0.34.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\n## Constants\n\n```go\nconst (\n\tHTTPStatusErrorMetadata = \"aserto-http-statuscode\"\n)\n```\n\n```go\nconst (\n\tMessageKey = \"msg\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\tErrUnknown = NewAsertoError(\"E00000\", codes.Internal, http.StatusInternalServerError, \"an unknown error has occurred\")\n)\n```\n\n## Functions\n\n```go\nfunc CustomErrorHandler(\n\tctx context.Context,\n\tgtw *runtime.ServeMux,\n\truntimeMarshaler runtime.Marshaler,\n\thttpResponseWriter http.ResponseWriter,\n\thttpRequest *http.Request,\n\terr error,\n)\n```\n\n```go\nfunc Logger(err error) *zerolog.Logger\n```\nLogger retrieves the most inner logger associated with an error.\n\n## Types\n\n```go\ntype AsertoError struct {\n\tCode     string\n\tGRPCCode codes.Code\n\tHTTPCode int\n\tMessage  string\n\t// contains filtered or unexported fields\n}\n```\nAsertoError represents a well known error coming from an Aserto service.\n\n```go\nfunc CodeToAsertoError(code string) *AsertoError\n```\n\n```go\nfunc FromGRPCStatus(grpcStatus status.Status) *AsertoError\n```\nFromGRPCStatus returns an Aserto error based on a given grpcStatus. The details that are not of type errdetails.ErrorInfo are dropped. and if there are details from multiple errors, the aserto error will be constructed based on the first one.\n\n```go\nfunc NewAsertoError(code string, grpcCode codes.Code, httpCode int, msg string) *AsertoError\n```\n\n```go\nfunc UnwrapAsertoError(err error) *AsertoError\n```\n\n```go\nfunc (e *AsertoError) Cause() error\n```\n\n```go\nfunc (e *AsertoError) Copy() *AsertoError\n```\n\n```go\nfunc (e *AsertoError) Ctx(ctx context.Context) error\n```\n\n```go\nfunc (e *AsertoError) Data() map[string]string\n```\n\n```go\nfunc (e *AsertoError) Err(err error) *AsertoError\n```\nErr associates err with the AsertoError, replacing any error previously associated via Err.\n\n```go\nfunc (e *AsertoError) Error() string\n```\n\n```go\nfunc (e *AsertoError) ErrorInfo(reason string) *errdetails.ErrorInfo\n```\nErrorInfo returns the errdetails.ErrorInfo for this error, with HTTPCode folded into Metadata under HTTPStatusErrorMetadata so it survives the grpc-gateway boundary (see CustomErrorHandler).\n\n```go\nfunc (e *AsertoError) Fields() map[string]any\n```\n\n```go\nfunc (e *AsertoError) GRPCStatus() *status.Status\n```\n\n```go\nfunc (e *AsertoError) MarshalZerologObject(event *zerolog.Event)\n```\n\n```go\nfunc (e *AsertoError) Msg(message string) *AsertoError\n```\n\n```go\nfunc (e *AsertoError) Msgf(message string, args ...any) *AsertoError\n```\n\n```go\nfunc (e *AsertoError) Str(key, value string) *AsertoError\n```\n\n```go\nfunc (e *AsertoError) Unwrap() error\n```\n\n```go\ntype ContextError struct {\n\tErr error\n\tCtx context.Context //nolint:containedctx\n}\n```\nContextError represents a standard error that can also encapsulate a context.\n\n```go\nfunc WithContext(err error, ctx context.Context) *ContextError\n```\n\n```go\nfunc WrapContext(err error, ctx context.Context, message string) *ContextError\n```\n\n```go\nfunc WrapfContext(err error, ctx context.Context, format string, args ...any) *ContextError\n```\n\n```go\nfunc (ce *ContextError) Cause() error\n```\n\n```go\nfunc (ce *ContextError) Error() string\n```\n\n```go\nfunc (ce *ContextError) Unwrap() error\n```\n\n","path":"github.com/aserto-dev/errors","name":"errors","synopsis":"","isRedistributable":true}
