zertosh / errorify

Browserify plugin to write failed build error messages to the output file
75 stars 2 forks source link

DOM / CSS #1

Closed mattdesl closed 9 years ago

mattdesl commented 9 years ago

I like the idea of this and would be interested in bringing it into my workflow, but I find Beefy's DOM-based error reporting (using <pre>) to be a bit cleaner and less jarring/disruptive than a modal alert().

There's also more potential for colors, err.stack, etc rather than just a string message.

Are you open to this? Or would you rather it be in another module?

A simple template ends up looking like this: (mostly from Beefy)

function(error) {
  console.error(error)
  var doc = typeof document === 'undefined' ? null : document
  if (!doc)
    return

  if(!doc.body) {
    return doc.addEventListener('DOMContentLoaded', function() {
      output()
    })
  } else
    output()

  function output() {
    var pre = doc.createElement('pre')
    pre.textContent = error
    if (doc.body.children.length)
      doc.body.insertBefore(pre, doc.body.children[0])
    else
      doc.body.appendChild(pre)
  }
}
zertosh commented 9 years ago

@mattdesl I like the idea - what do you think of this? https://github.com/zertosh/errorify/pull/2

zertosh commented 9 years ago

Published as errorify@0.1.0