errors: add new function Sub #496

Merged
merged 7 commits into from Feb 9, 2017

Projects

None yet

3 participants

@kr
Member
kr commented Feb 8, 2017 edited

Sub takes an existing error, which might have an associated stack trace or other metadata, and substitutes a new root error, which is sometimes necessary to return a certain error code to the client.

This change also updates all call sites I could find to use the new function.

@kr kr added the PTAL label Feb 9, 2017
@kr
Member
kr commented Feb 9, 2017

PTAL

+// Use this when you need to substitute a new root error in place
+// of an existing error that may already hold a stack trace
+// or other metadata.
+func Sub(new, old error) error {
@jbowens
jbowens Feb 9, 2017 Member

I don't mind but new might look a little weird with syntax highlighting.

@kr
kr Feb 9, 2017 Member

Hmm, personally I prefer it as new; that seems like the right name to me. (Syntax highlighting ought to know that new is a valid variable name.)

@jbowens
jbowens approved these changes Feb 9, 2017 View changes
@jbowens
Member
jbowens commented Feb 9, 2017

lgtm besides the nit on the variable name

kr added some commits Feb 8, 2017
@kr @chainbot kr wip 30a152a
@kr @chainbot kr examples ec8debb
@kr @chainbot kr replace all known cases 65e62ce
@kr @chainbot kr tweak wording 754d325
@kr @chainbot kr add tests and fix a message formatting bug 1ae1379
@kr @chainbot kr go vet 88c5759
@kr kr bump wercker
fc0aeee
@chainbot chainbot merged commit 061cf26 into main Feb 9, 2017

3 checks passed

licence/cla Contributor License Agreement is signed.
Details
wercker/cored Wercker pipeline passed
Details
wercker/java Wercker pipeline passed
Details
@chainbot chainbot deleted the err-sub branch Feb 9, 2017
@kr kr referenced this pull request Feb 9, 2017
Merged

errors: clarify documentation #500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment