Closed tusharmath closed 9 years ago
Would this be enough:
$ npm install pretty-error renderkid domutils
then:
PrettyError = require 'pretty-error'
renderkidTools = require 'renderkid/lib/tools'
DomUtils = require 'domutils'
pe = new PrettyError
errorObject = new Error "error message"
shortDomNotation = pe.getObject errorObject
errorDom = renderkidTools.objectToDom errorObject
errorHtml = DomUtils.getOuterHTML errorDom
console.log errorHtml
The output would be:
<pretty-error>
<header>
<title>
...
Will this output a pretty version of the stacktrace on the browser?
Just the HTML without any CSS, so you'd need to write some CSS to make it look pretty.
If you want to use the console's theme in the browser, there are two ways to do that:
prettyError._renderer._styles
(which is the object that handles the stylesheet rules in RenderKid), and converts it to pure CSS rules. Most of RenderKid's css can be directly converted to CSS. The bullet points are implemented differently though, so you'll have to come up with a way to convert RenderKid's bullet
property to a browser-readable CSS property.The second way is automatic, but I think it's an overkill. I'd recommend just rewriting PrettyError's CSS rules by hand.
I'm closing this issue since it hasn't been active for a while.
Not the right reason to close the issu .
No problem. Let me know if my explanation in this comment was useful. I'll be happy to help with implementing a separate HTML converter for pretty-error.
Can you reopen this.
It would be good if it returned pure html with inline css styling just like https://github.com/benbria/exception-formatter does.
That way we can use the output directly in a website.
There should be a way to prettify the error messages in html form. So that one can use it as a middleware for express.