tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

helpful-error-messages.rst (1424B)


      1 Helpful error messages for web developers
      2 ===========================================
      3 
      4 When errors are surfaced to the web platform, developers see them in the console on their local machine, or they may be using an error tracking system to record errors happening on their users' machines.
      5 
      6 This means developers may be exposed to our error messages even if they aren't developing in Firefox.
      7 
      8 Vague error messages are frustrating experiences and negatively impacts Firefox, especially if, in their logs, developers are seeing more helpful messages from other browsers.
      9 
     10 Instead:
     11 
     12 - Explain why this specific error happened.
     13 - Use terms familiar to web developers.
     14 - If there's a likely solution, suggest it.
     15 - Link to MDN, so the developer has an immediate way to learn about the requirements of the API.
     16 
     17 Example
     18 -------
     19 
     20 Given error-throwing code like:
     21 
     22 .. code-block:: js
     23 
     24   const urlPattern = new URLPattern('/blog/:year/:title');
     25 
     26 .. admonition:: Bad example
     27   :class: warning
     28 
     29   Uncaught TypeError: URLPattern constructor: Failed to create URLPattern (from string)
     30 
     31 .. admonition:: Better example
     32   :class: tip
     33 
     34   Throw something like: Uncaught TypeError: URLPattern constructor: Relative pattern '/blog/:year/:title' must have a base URL passed as the second argument, or use an object as the first argument to match specific parts of URLs. See https://developer.mozilla.org/docs/Web/API/URLPattern/URLPattern