New is a drop in replacement for the standard library errors module that records the location that the error is created. For example: return errors.New("validation failed")
(message string)
| 17 | // return errors.New("validation failed") |
| 18 | // |
| 19 | func New(message string) error { |
| 20 | err := &Err{message: message} |
| 21 | err.SetLocation(1) |
| 22 | return err |
| 23 | } |
| 24 | |
| 25 | // Errorf creates a new annotated error and records the location that the |
| 26 | // error is created. This should be a drop in replacement for fmt.Errorf. |