diff --git a/api.go b/api.go index 3eb75a5..4deb417 100644 --- a/api.go +++ b/api.go @@ -3,6 +3,7 @@ package telebot import ( "bytes" "encoding/json" + "fmt" "io" "io/ioutil" "log" @@ -12,8 +13,6 @@ import ( "strconv" "strings" "time" - - "github.com/pkg/errors" ) // Raw lets you call any method of Bot API manually. @@ -73,7 +72,7 @@ func (b *Bot) sendFiles(method string, files map[string]File, params map[string] case f.FileReader != nil: rawFiles[name] = f.FileReader default: - return nil, errors.Errorf("telebot: file for field %s doesn't exist", name) + return nil, fmt.Errorf("telebot: file for field %s doesn't exist", name) } } @@ -140,7 +139,7 @@ func addFileToWriter(writer *multipart.Writer, filename, field string, file inte defer f.Close() reader = f } else { - return errors.Errorf("telebot: file for field %v should be io.ReadCloser or string", field) + return fmt.Errorf("telebot: file for field %v should be io.ReadCloser or string", field) } part, err := writer.CreateFormFile(field, filename) diff --git a/bot.go b/bot.go index 99c74a4..cd16ab4 100644 --- a/bot.go +++ b/bot.go @@ -9,8 +9,6 @@ import ( "regexp" "strconv" "strings" - - "github.com/pkg/errors" ) // NewBot does try to build a Bot with token `token`, which @@ -600,7 +598,7 @@ func (b *Bot) SendAlbum(to Recipient, a Album, opts ...interface{}) ([]Message, repr = "attach://" + strconv.Itoa(i) files[strconv.Itoa(i)] = *file default: - return nil, errors.Errorf("telebot: album entry #%d does not exist", i) + return nil, fmt.Errorf("telebot: album entry #%d does not exist", i) } im := x.InputMedia() @@ -890,7 +888,7 @@ func (b *Bot) EditMedia(msg Editable, media Inputtable, opts ...interface{}) (*M repr = "attach://" + s files[s] = *file default: - return nil, errors.Errorf("telebot: cannot edit media, it does not exist") + return nil, fmt.Errorf("telebot: cannot edit media, it does not exist") } switch m := media.(type) { @@ -1152,7 +1150,7 @@ func (b *Bot) File(file *File) (io.ReadCloser, error) { if resp.StatusCode != http.StatusOK { resp.Body.Close() - return nil, errors.Errorf("telebot: expected status 200 but got %s", resp.Status) + return nil, fmt.Errorf("telebot: expected status 200 but got %s", resp.Status) } return resp.Body, nil diff --git a/context.go b/context.go index a71156a..a06e5ae 100644 --- a/context.go +++ b/context.go @@ -1,11 +1,10 @@ package telebot import ( + "errors" "strings" "sync" "time" - - "github.com/pkg/errors" ) // HandlerFunc represents a handler function, which is diff --git a/go.mod b/go.mod index 4292f45..93eb46d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/fatih/color v1.13.0 // indirect github.com/goccy/go-yaml v1.9.5 github.com/mattn/go-colorable v0.1.12 // indirect - github.com/pkg/errors v0.9.1 github.com/spf13/cast v1.3.1 github.com/stretchr/testify v1.7.0 golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect diff --git a/go.sum b/go.sum index 5b55c1b..f2a8757 100644 --- a/go.sum +++ b/go.sum @@ -23,8 +23,6 @@ github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= diff --git a/inline.go b/inline.go index 047af7f..b369139 100644 --- a/inline.go +++ b/inline.go @@ -3,8 +3,6 @@ package telebot import ( "encoding/json" "fmt" - - "github.com/pkg/errors" ) // Query is an incoming inline query. When the user sends @@ -134,7 +132,7 @@ func inferIQR(result Result) error { case *StickerResult: r.Type = "sticker" default: - return errors.Errorf("telebot: result %v is not supported", result) + return fmt.Errorf("telebot: result %v is not supported", result) } return nil diff --git a/telebot.go b/telebot.go index 48dc8ad..8c4f0ca 100644 --- a/telebot.go +++ b/telebot.go @@ -27,7 +27,7 @@ // package telebot -import "github.com/pkg/errors" +import "errors" var ( ErrBadRecipient = errors.New("telebot: recipient is nil") diff --git a/util.go b/util.go index 6c355d9..49ad60d 100644 --- a/util.go +++ b/util.go @@ -7,8 +7,6 @@ import ( "log" "net/http" "strconv" - - "github.com/pkg/errors" ) var defaultOnError = func(err error, c Context) { @@ -24,7 +22,7 @@ func (b *Bot) deferDebug() { if err, ok := r.(error); ok { b.debug(err) } else if str, ok := r.(string); ok { - b.debug(errors.Errorf("%s", str)) + b.debug(fmt.Errorf("%s", str)) } } } @@ -52,7 +50,7 @@ func applyMiddleware(h HandlerFunc, middleware ...MiddlewareFunc) HandlerFunc { // wrapError returns new wrapped telebot-related error. func wrapError(err error) error { - return errors.Wrap(err, "telebot") + return fmt.Errorf("telebot: %w", err) } // extractOk checks given result for error. If result is ok returns nil.