donejs / done-serve

DoneJS development server
https://www.npmjs.com/package/done-serve
MIT License
7 stars 5 forks source link

Create a better designed error handler page #100

Closed matthewp closed 6 years ago

matthewp commented 6 years ago

Currently errors are forwarded to the client as text. Since this is a development tool we should do a better job of designing these.

matthewp commented 6 years ago

Here's the plan on the design:

  1. We will handle errors directly instead of letting it go through express (which just forwards them to the client as text).
  2. The error will be passed to https://github.com/donejs/donejs-error-format which will extract the relevant parts of the error message.
  3. errorFormat.html(parts) -> HTML will give us back the HTML.
  4. We will clear the console (create-react-app does the same, giving the error message more focus).
  5. errorFormat.console(parts) -> Text will give us formatted Text that can be logged to the console.
matthewp commented 6 years ago

Usage like this:

const errorFormat = require("donejs-error-format");

app.use(function(err, req, res, next){
  let parts = errorFormat.extract(err);
  let html = errorFormat.html(parts);

  // TODO format the console version, clear, and log

  res.type('html').end(html);
});
matthewp commented 6 years ago

https://github.com/donejs/donejs-error-format

matthewp commented 6 years ago

This was done in #102