Categorygithub.com/gravitational/trace
modulepackage
1.5.0
Repository: https://github.com/gravitational/trace.git
Documentation: pkg.go.dev

# README

Trace

GoDoc Test workflow

Package for error handling and error reporting

Read more here:

https://goteleport.com/blog/golang-error-handling/

Capture file, line and function


import (
     "github.com/gravitational/trace"
)

func someFunc() error {
   return trace.Wrap(err)
}


func main() {
  err := someFunc()
  fmt.Println(err.Error()) // prints file, line and function
}

# Functions

AccessDenied returns new instance of AccessDeniedError.
AlreadyExists returns a new instance of AlreadyExists error.
BadParameter returns a new instance of BadParameterError.
CompareFailed returns new instance of CompareFailedError.
ConnectionProblem returns new instance of ConnectionProblemError.
ConvertSystemError converts system error to appropriate trace error if it is possible, otherwise, returns original error.
DebugReport returns debug report with all known information about the error including stack trace if it was captured.
Errorf is similar to fmt.Errorf except that it captures more information about the origin of error, such as callee, line number and function that simplifies debugging.
ErrorToCode returns an appropriate HTTP status code based on the provided error type.
Fatalf - If debug is false Fatalf calls Errorf.
GetFields returns any fields that have been added to the error message.
IsAccessDenied returns true if `e` contains an [AccessDeniedError] in its chain.
IsAggregate returns true if `err` contains an [Aggregate] error in its chain.
IsAlreadyExists returns true if `e` contains an [AlreadyExistsError] in its chain.
IsBadParameter returns true if `e` contains a [BadParameterError] in its chain.
IsCompareFailed returns true if `e` contains a [CompareFailedError] in its chain.
IsConnectionProblem returns true if `e` contains a [ConnectionProblemError] in its chain.
IsDebug returns true if debug mode is on.
IsEOF returns true if the passed error is io.EOF.
IsLimitExceeded returns true if `e` contains a [LimitExceededError] in its chain.
IsNotFound returns true if `e` contains a [NotFoundError] in its chain.
IsNotImplemented returns true if `e` contains a [NotImplementedError] in its chain.
IsOAuth2 returns true if `e` contains an [OAuth2Error] in its chain.
IsRetryError returns true if `e` contains a [RetryError] in its chain.
IsTrustError returns true if `e` contains a [TrustError] in its chain.
LimitExceeded returns whether new instance of LimitExceededError.
NewAggregate creates a new aggregate instance from the specified list of errors.
NewAggregateFromChannel creates a new aggregate instance from the provided errors channel.
NotFound returns new instance of not found error.
NotImplemented returns a new instance of NotImplementedError.
OAuth2 returns new instance of OAuth2Error.
ReadError converts http error to internal error type based on HTTP response code and HTTP body contents if status code does not indicate error, it will return nil.
Retry returns new instance of RetryError which indicates a transient error type.
SetDebug turns on/off debugging mode, that causes Fatalf to panic.
Trust returns new instance of TrustError.
Unwrap returns the original error the given error wraps.
UserMessage returns user-friendly part of the error.
UserMessageWithFields returns user-friendly error with key-pairs as part of the message.
WithField adds additional field information to the error.
WithFields adds a map of additional fields to the error.
WithUserMessage adds formatted user-facing message to the error, depends on the implementation, usually works as fmt.Sprintf(formatArg, rest...) but implementations can choose another way, e.g.
Wrap takes the original error and wraps it into the Trace struct memorizing the context of the error.
WrapWithMessage wraps the original error into Error and adds user message if any.
WriteError sets up HTTP error response and writes it to writer w.

# Structs

AccessDeniedError indicates denied access.
AlreadyExistsError indicates that there's a duplicate object that already exists in the storage/system.
BadParameterError indicates that something is wrong with passed parameter to API method.
CompareFailedError indicates a failed comparison (e.g.
ConnectionProblemError indicates a network related problem.
LimitExceededError indicates rate limit or connection limit problem.
NotFoundError indicates that object has not been found.
NotImplementedError defines an error condition to describe the result of a call to an unimplemented API.
OAuth2Error defined an error used in OpenID Connect Flow (OIDC).
RawTrace describes the error trace on the wire.
RetryError indicates a transient error type.
TraceErr contains error message and some additional information about the error origin.
TrustError indicates trust-related validation error (e.g.

# Interfaces

Aggregate interface combines several errors into one error.
DebugReporter formats an error for display.
Error is an interface that helps to adapt usage of trace in the code When applications define new error types, they can implement the interface Error handlers can use Unwrap() to retrieve error from the wrapper, or errors.Is()/As() to compare it to another value.
ErrorWrapper wraps another error.
UserMessager returns a user message associated with the error.

# Type aliases

Fields maps arbitrary keys to values inside an error.
No description provided by the author
No description provided by the author