Debian Codegraph @

fmt/errors/errors.go

raw symbols SCIP
1 // Package errors is the same as gopkg.in/errgo.v2/errors except that
2 // it adds convenience functions that use the fmt package to format
3 // error messages.
4 package errors
5
6 import (
7 "fmt"
8
9 "gopkg.in/errgo.v2/errors"
10 )
11
12 // Newf is like New except it formats the message with a fmt
13 // format specifier.
14 func Newf(format string, a ...interface{}) error {
15 err := errors.New(fmt.Sprintf(format, a...))
16 errors.SetLocation(err, 1)
17 return err
18 }
19
20 // Notef is like Note except it formats the message with a fmt
21 // format specifier.
22 func Notef(err error, shouldPreserveCause func(error) bool, format string, a ...interface{}) error {
23 err = Note(err, shouldPreserveCause, fmt.Sprintf(format, a...))
24 errors.SetLocation(err, 1)
25 return err
26 }
27
28 // Becausef is like Because except it formats the message with a fmt
29 // format specifier.
30 func Becausef(err, cause error, format string, a ...interface{}) error {
31 err = Because(err, cause, fmt.Sprintf(format, a...))
32 errors.SetLocation(err, 1)
33 return err
34 }