godropbox: github.com/dropbox/godropbox/errors Index | Files

package errors

import "github.com/dropbox/godropbox/errors"

This module implements functions which manipulate errors and provide stack trace information.

NOTE: This package intentionally mirrors the standard "errors" module. All dropbox code should use this.

Index

Package Files

errors.go

func GetMessage Uses

func GetMessage(err interface{}) string

This returns the error string without stack trace information.

func IsError Uses

func IsError(err, errConst error) bool

Perform a deep check, unwrapping errors as much as possilbe and comparing the string version of the error.

func RootError Uses

func RootError(ierr error) (nerr error)

Keep peeling away layers or context until a primitive error is revealed.

type DropboxError Uses

type DropboxError interface {
    // This returns the error message without the stack trace.
    GetMessage() string

    // This returns the wrapped error.  This returns nil if this does not wrap
    // another error.
    GetInner() error

    // Implements the built-in error interface.
    Error() string

    // Returns stack addresses as a string that can be supplied to
    // a helper tool to get the actual stack trace. This function doesn't result
    // in resolving full stack frames thus is a lot more efficient.
    StackAddrs() string

    // Returns stack frames.
    StackFrames() []StackFrame

    // Returns string representation of stack frames.
    // Stack frame formatting looks generally something like this:
    // dropbox/rpc.(*clientV4).Do
    //   /srv/server/go/src/dropbox/rpc/client.go:87 +0xbf9
    // dropbox/exclog.Report
    //   /srv/server/go/src/dropbox/exclog/client.go:129 +0x9e5
    // main.main
    //   /home/cdo/tmp/report_exception.go:13 +0x84
    // It is discouraged to parse stack frames using string parsing since it can change at any time.
    // Use StackFrames() function instead to get actual stack frame metadata.
    GetStack() string
}

This interface exposes additional information about the error.

func New Uses

func New(msg string) DropboxError

This returns a new baseError initialized with the given message and the current stack trace.

func Newf Uses

func Newf(format string, args ...interface{}) DropboxError

Same as New, but with fmt.Printf-style parameters.

func Wrap Uses

func Wrap(err error, msg string) DropboxError

Wraps another error in a new baseError.

func Wrapf Uses

func Wrapf(err error, format string, args ...interface{}) DropboxError

Same as Wrap, but with fmt.Printf-style parameters.

type StackFrame Uses

type StackFrame struct {
    PC         uintptr
    Func       *runtime.Func
    FuncName   string
    File       string
    LineNumber int
}

Represents a single stack frame.

Package errors imports 5 packages (graph) and is imported by 512 packages. Updated 2018-11-04. Refresh now. Tools for package owners.