errors: add new function Sub #496

merged 7 commits into from Feb 9, 2017


None yet

3 participants

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 commented Feb 9, 2017


+// 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 Feb 9, 2017 Member

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

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 approved these changes Feb 9, 2017 View changes
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
@chainbot chainbot merged commit 061cf26 into main Feb 9, 2017

3 checks passed

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

errors: clarify documentation #500

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