Skip to content

Commit

Permalink
feat: use std errors.New when not tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Nov 3, 2021
1 parent 2ebf677 commit 1baefaa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package errors

import "fmt"
import (
"errors"
"fmt"
)

// errorString is a trivial implementation of error.
type errorString struct {
Expand All @@ -18,14 +21,12 @@ type errorString struct {
// implements Formatter to show this information when printed with details.
func New(text string) error {
if !Trace() {
return &errorString{s: text}
return errors.New(text)
}
return &errorString{text, Caller(1)}
}

func (e *errorString) Error() string {
return e.s
}
func (e *errorString) Error() string { return e.s }

func (e *errorString) Format(s fmt.State, v rune) { FormatError(e, s, v) }

Expand Down

0 comments on commit 1baefaa

Please sign in to comment.