nyaruka / courier

Messaging gateway for RapidPro/TextIt.
Other
114 stars 68 forks source link

Use std library errors #745

Closed rowanseymour closed 1 month ago

rowanseymour commented 3 months ago

Remove github.com/pkg/errors which is dead like in https://github.com/nyaruka/gocommon/pull/128 and https://github.com/nyaruka/goflow/pull/1258

rowanseymour commented 3 months ago

can use find and replace with regex for some of this...

errors\.Wrap\(err, "([^"]+)"\) > fmt.Errorf("$1: %w", err)

rowanseymour commented 3 months ago

Even better....

errors\.Wrapf?\(err, "([^"]+)"(.*)\)$
fmt.Errorf("$1: %w"$2, err)
rowanseymour commented 3 months ago

BUT... errors.Wrap and errors.Wrapf return nil if passed a nil error... fmt.Errorf doesn't... so you gotta look for cases where we were relying on that. You can find some with ^\treturn fmt\.Errorf\( which are lines returning an err which aren't indented in an if

norkans7 commented 3 months ago

Yes, I suspect that is causing issues in backends/rapidpro I will update that part in a second PR