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.
I don't mind but new might look a little weird with syntax highlighting.
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.)
lgtm besides the nit on the variable name
replace all known cases
add tests and fix a message formatting bug