errors

package
v0.0.0-...-6a50f26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2015 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultError

func DefaultError(e DropboxError) string

A default implementation of the Error method of the error interface.

func GetMessage

func GetMessage(err interface{}) string

This returns the error string without stack trace information.

func StackTrace

func StackTrace() (current, context string)

This returns the current stack trace string. NOTE: the stack creation code is excluded from the stack trace.

Types

type DropboxBaseError

type DropboxBaseError struct {
	Msg     string
	Stack   string
	Context string
	// contains filtered or unexported fields
}

Standard struct for general types of errors.

For an example of custom error type, look at databaseError/newDatabaseError in errors_test.go.

func (*DropboxBaseError) Error

func (e *DropboxBaseError) Error() string

This returns a string with all available error information, including inner errors that are wrapped by this errors.

func (*DropboxBaseError) GetContext

func (e *DropboxBaseError) GetContext() string

This returns the stack trace's context.

func (*DropboxBaseError) GetInner

func (e *DropboxBaseError) GetInner() error

This returns the wrapped error, if there is one.

func (*DropboxBaseError) GetMessage

func (e *DropboxBaseError) GetMessage() string

This returns the error message without the stack trace.

func (*DropboxBaseError) GetStack

func (e *DropboxBaseError) GetStack() string

This returns the stack trace without the error message.

type DropboxError

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

	// This returns the stack trace without the error message.
	GetStack() string

	// This returns the stack trace's context.
	GetContext() 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
}

This interface exposes additional information about the error.

func New

func New(msg string) DropboxError

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

func Newf

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

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

func Wrap

func Wrap(err error, msg string) DropboxError

Wraps another error in a new DropboxBaseError.

func Wrapf

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL