Labs/Jetpack/So You're Implementing a JEP: Difference between revisions

Jump to navigation Jump to search
→‎Exceptions: rephrased explanation of why we never throw raw strings
(Copied from User:Adw/JEP-fu)
 
(→‎Exceptions: rephrased explanation of why we never throw raw strings)
Line 129: Line 129:
= Exceptions =
= Exceptions =


Atul's code throws <tt>new Error()</tt>s, so that's what you should do too. No raw strings.
Never throw raw strings, because <tt>console.exception()</tt>, which is ultimately used to log any exceptions in Jetpack, can't introspect a string to get at any additional information about where the error came from. Instead, throw a <tt>new Error()</tt>, which automatically adds metadata about the state of the stack at the time the error was thrown. This allows us to provide helpful tracebacks to developers.


Being friendly to developers is an important part of Jetpack.  Therefore, all error messages that developers might see should be informative and punctuated full sentences.
Being friendly to developers is an important part of Jetpack.  Therefore, all error messages that developers might see should be informative and punctuated full sentences.
874

edits

Navigation menu