Skip to content

Commit

Permalink
Merge pull request #10 from gregwebs/docs-deprecation
Browse files Browse the repository at this point in the history
update docs around deprecation
  • Loading branch information
gregwebs authored Sep 20, 2018
2 parents 0c849bc + 017f38e commit 31ffda8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 10 additions & 7 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (f *fundamental) Format(s fmt.State, verb rune) {
// WithStack annotates err with a stack trace at the point WithStack was called.
// If err is nil, WithStack returns nil.
//
// Deprecated: use AddStack
// For most use cases this is deprecated and AddStack should be used (which will ensure just one stack trace).
// However, one may want to use this in some situations, for example to create a 2nd trace across a goroutine.
func WithStack(err error) error {
if err == nil {
return nil
Expand Down Expand Up @@ -197,10 +198,11 @@ func (w *withStack) Format(s fmt.State, verb rune) {
}

// Wrap returns an error annotating err with a stack trace
// at the point Annotate is called, and the supplied message.
// If err is nil, Annotate returns nil.
// at the point Wrap is called, and the supplied message.
// If err is nil, Wrap returns nil.
//
// Deprecated: use Annotate instead
// For most use cases this is deprecated in favor of Annotate.
// Annotate avoids creating duplicate stack traces.
func Wrap(err error, message string) error {
if err == nil {
return nil
Expand All @@ -218,10 +220,11 @@ func Wrap(err error, message string) error {
}

// Wrapf returns an error annotating err with a stack trace
// at the point Annotatef is call, and the format specifier.
// If err is nil, Annotatef returns nil.
// at the point Wrapf is call, and the format specifier.
// If err is nil, Wrapf returns nil.
//
// Deprecated: use Annotatef instead
// For most use cases this is deprecated in favor of Annotatef.
// Annotatef avoids creating duplicate stack traces.
func Wrapf(err error, format string, args ...interface{}) error {
if err == nil {
return nil
Expand Down
7 changes: 5 additions & 2 deletions juju_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (

// ==================== juju adaptor start ========================

// Trace annotates err with a stack trace at the point WithStack was called.
// If err is nil or already contain stack trace return directly.
// Trace just calls AddStack.
func Trace(err error) error {
return AddStack(err)
}

// Annotate adds a message and ensures there is a stack trace.
func Annotate(err error, message string) error {
if err == nil {
return nil
Expand All @@ -31,6 +31,7 @@ func Annotate(err error, message string) error {
}
}

// Annotatef adds a message and ensures there is a stack trace.
func Annotatef(err error, format string, args ...interface{}) error {
if err == nil {
return nil
Expand All @@ -51,6 +52,8 @@ func Annotatef(err error, format string, args ...interface{}) error {
}

// ErrorStack will format a stack trace if it is available, otherwise it will be Error()
// If the error is nil, the empty string is returned
// Note that this just calls fmt.Sprintf("%+v", err)
func ErrorStack(err error) string {
if err == nil {
return ""
Expand Down

0 comments on commit 31ffda8

Please sign in to comment.