ariaminaei / pretty-error Goto Github PK
View Code? Open in Web Editor NEWSee node.js errors with less clutter
License: MIT License
See node.js errors with less clutter
License: MIT License
I create a module called evalmd
that evaluates markdown files. Ideally I'd only want to show the trace of the markdown file. I don't expect this to be a feature of pretty-error, but I'd like to skip stack trace lines by extension. How after I edit a trace could I assemble the error again? I can't seem to overwrite the parsedError.trace
variable and throw parsedError
. @AriaMinaei thoughts?
var ParsedError = require('pretty-error/lib/parsed-error')
var _ = require('lodash')
var parsedError = new ParsedError(err)
var newTrace = _.filter(parsedError.trace, function (line) {
var validExt = ['.md', '.markdown']
var lineExt = path.extname(line.file)
var isMarkdown = _.contains(validExt, lineExt)
return isMarkdown
})
I'm I stuck having to stitch all the pieces together by hand? Or does pretty-error
have a way to do this?
Ideally I could:
parsedError.setTrace(trace)
parsedError
back to a error parsedError.toError()
I want to use the error parser because I want to show the code frame. To skip packages which are filtered too It were nice there would be a way to use the applied filters on an own parsed error.
a little test (win10, node 6.9.1) shows:
C:\l\Neuer Ordner\node_modules\license-compatibility-checker\index.js:12
f
^
�[0m�[97m�[41mReferenceError�[0m�[90m:�[0m�[37m �[0m�[97mf is not defined�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mindex.js�[0m�[90m:�[0m�[93m12�[0m�[37m �[0m�[37mObject.<anonymous>�[0m
�[0m �[0m �[0m�[90m[Neuer Ordner]/[license-compatibility-checker]/index.js:12:1�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m570�[0m�[37m �[0m�[37mModule._compile�[0m
�[0m �[0m �[0m�[90mmodule.js:570:32�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m579�[0m�[37m �[0m�[37mObject.Module._extensions..js�[0m
�[0m �[0m �[0m�[90mmodule.js:579:10�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m487�[0m�[37m �[0m�[37mModule.load�[0m
�[0m �[0m �[0m�[90mmodule.js:487:32�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m446�[0m�[37m �[0m�[37mtryModuleLoad�[0m
�[0m �[0m �[0m�[90mmodule.js:446:12�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m438�[0m�[37m �[0m�[37mFunction.Module._load�[0m
�[0m �[0m �[0m�[90mmodule.js:438:3�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m497�[0m�[37m �[0m�[37mModule.require�[0m
�[0m �[0m �[0m�[90mmodule.js:497:17�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m20�[0m�[37m �[0m�[37mrequire�[0m
�[0m �[0m �[0m�[90minternal/module.js:20:19�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mt.js�[0m�[90m:�[0m�[93m3�[0m�[37m �[0m�[37mObject.<anonymous>�[0m
�[0m �[0m �[0m�[90mC:/l/Neuer Ordner/t.js:3:12�[0m
�[0m �[0m
�[0m �[0m�[90m-�[0m �[0m�[93mmodule.js�[0m�[90m:�[0m�[93m570�[0m�[37m �[0m�[37mModule._compile�[0m
�[0m �[0m �[0m�[90mmodule.js:570:32�[0m
�[0m �[0m
�[0m
Love the work you are doing! Thanks a ton for this module. My only wish is that by default it wouldn't hardwrap lines. Feels that this should be an opt-in, and I don't see an easy way of disabling it either.
What do you think?
I want to integrate the library with my error library Errorifier. Basically in my library I create a Error Object, I add a little logic and return the logic. Something like:
constructor: ->
err = new Error()
# adding logic
err
Externally is used like:
err = new Errorifier()
console.log err # normal output
The point is: I want to integrate with the library to, when you use console.log, see the outputted generate by the method .render
, like:
err = new Errorifier()
console.log err # pretty output!
I didn't find a way to do it and still return the err object in my library constructor.
Do you think that this is possible? If is necessary, I can extends PrettyError
.
Is there a way to prevent the render from adding a \n
?
Hi,
I just discovered your module, which is really nice for mental sanity when looking at errors! Thank you.
I see that for node modules paths (dependencies), by default, the full path to the app root directory has an alias. Something like "[name-of-the-app]"
But this is not the case for the app code itself. How can we do the same for any path?
I had an issue where I needed to obtain an un-modified stack trace for another package to parse information out of. In the end I solved it as:
pe.stop();
const stack = (new Error()).stack;
pe.start();
It took some digging and intuition to find .stop() so it would be helpful if this was mentioned in the readme.
The reason I didn't individually format errors instead of .start() is that I have many places where errors may be output, but only one where I need this raw trace.
Question: Is the original .stack stored anywhere? I think it would be great to be able to access it, as well as the ParsedError (to eliminate the need for other parsing packages since the message is parsed once here anyway)
module.js:333
throw err;
^
Error: Cannot find module 'CSSSelect'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (.../pretty-error/node_modules/renderkid/scripts/js/lib/renderKid/styles/rule/Selector.js:3:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
make: *** [web] Error 1
Stack traces are in generall have a not-ideal representation for CLI. If the stack is longer the message and the first trace item is at the beginning of the stack output.
It would be nice if there were an option to reverse the output.
item 3
item 2
item 1
Error: The error message
This is lot easier to read, try it out!
Also I show a code frame (using babel code frame) of the last trace item. The problem currently is that the code frame represents the first entry, and the first entry, which stands at the first position of the list.
So there should be 2 options:
@AriaMinaei how do I wrap pretty-error > trace > item > footer > addr
in parens? I need :before
and :after
selectors. Are there any other default declarations I can use?
var _ = require('lodash')
var PrettyError = require('pretty-error')
var pe = new PrettyError()
var nullStyle = {
display: 'inline',
background: 'none',
color: 'none',
bullet: 'none',
paddingLeft: 0,
paddingRight: 0,
paddingBottom: 0,
paddingTop: 0,
marginLeft: 0,
marginRight: 0,
marginBottom: 0,
marginTop: 0
}
pe.appendStyle({
'pretty-error': _.defaults({}, nullStyle),
'pretty-error > header': nullStyle,
'pretty-error > header > title > kind': nullStyle,
'pretty-error > header > colon': _.defaults({
marginRight: 1
}, nullStyle),
'pretty-error > header > message': nullStyle,
'pretty-error > trace': _.defaults({
display: 'block',
marginLeft: 4
}, nullStyle),
'pretty-error > trace > item': _.defaults({
display: 'block',
bullet: '"at "'
}, nullStyle),
'pretty-error > trace > item > header': _.defaults({
}, nullStyle),
'pretty-error > trace > item > header > pointer > file': _.defaults({
display: 'none'
}, nullStyle),
'pretty-error > trace > item > header > pointer > colon': _.defaults({
display: 'none'
}, nullStyle),
'pretty-error > trace > item > header > pointer > line': _.defaults({
display: 'none'
}, nullStyle),
'pretty-error > trace > item > header > what': _.defaults({
}, nullStyle),
'pretty-error > trace > item > footer': _.defaults({
}, nullStyle),
'pretty-error > trace > item > footer > addr': _.defaults({
// bullet: '"("'
}, nullStyle),
'pretty-error > trace > item > footer > extra': nullStyle
})
var e = new Error('Some error message')
var renderedError = pe.render(e)
console.log("///// native error")
console.log(e.stack)
console.log("///// pretty error")
console.log(renderedError)
Is giving me this:
///// native error
Error: Some error message
at Object.<anonymous> (/Users/thomas/Desktop/node-reggi/z-multi-line.js:78:9)
at Module._compile (module.js:430:26)
at Object.Module._extensions..js (module.js:448:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:471:10)
at startup (node.js:117:18)
at node.js:953:3
///// pretty error
Error: Some error message
at Object.<anonymous>/Users/thomas/Desktop/node-reggi/z-multi-line.js:78:9
at Module._compilemodule.js:430:26
at Object.Module._extensions..jsmodule.js:448:10
at Module.loadmodule.js:355:32
at Function.Module._loadmodule.js:310:12
at Function.Module.runMainmodule.js:471:10
at startupnode.js:117:18
at node.js:953:3
Hi! I need to address some vulnerabilities including one for css-what
https://www.npmjs.com/advisories/1754 which is a dependency for renderkid
and fixed in renderkid 2.0.7
Would it be possible to update renderkid
from 2.0.7-dev.1
(if it is in fact needed?) and also to release a new version of pretty-error
(seems needed regardless as the latest has renderkid 2.0.6
)?
If helpful for me to do a PR that bumps renderkid, please let me know 😄 I wanted to check in with you first!
Line 18 in e0ae9d2
I would like to get rid of the blank lines and have each stack trace entry take only one line (with the path on the same line).
Simply changing the colors isn't enough for me, it'd be awesome if it was possible create completely custom themes, template and styles.
Webpack uses query strings for it loaders.
When executing webpack code with source maps and pretty-error I get invalid file names:
- loader.js:10 eval
/a/path/template.jade?/a/path/loader.js:10:57
I would expect template.jade
however pretty error displays loader.js
.
It seems as though the error's message is stripped if a stack trace is present (ParsedError.coffee:25):
if typeof @_stack is 'string'
@_parseStack()
else
@_message = @error.message? and String(@error.message) or ''
There should be a way to prettify the error messages in html form. So that one can use it as a middleware for express.
It would be useful to be able to npm install -g pretty-error
, and get a pe-node
binary or something like that, that enables pretty errors for whatever script you are trying to run - supporting something like --ignore-node
and --ignore-module
arguments for basic configuration. That way you don't have to hardcode it into your application or library, but you can still get pretty errors during development.
Is anything like this planned?
EDIT: For clarification, an invocation would look something like pe-node --ignore-node --ignore-module bluebird app.js
example code:
var pe = new (require("pretty-error"));
try {
eval(`(function fn(){
throw new Error('some error');
})()`)
} catch(e) {
console.log(e.stack);
console.log(pe.render(e));
}
result:
Error: some error
at fn (eval at <anonymous> (S:\_TEST_\index.js:4:2), <anonymous>:2:9)
at eval (eval at <anonymous> (S:\_TEST_\index.js:4:2), <anonymous>:3:4)
at Object.<anonymous> (S:\_TEST_\index.js:4:2)
at Module._compile (module.js:570:32)
Error: some error
- index.js:4 Object.<anonymous>
S:/_TEST_/index.js:4:2
- module.js:570 Module._compile
module.js:570:32
I'm building an application which really needs nested errors. The fs can throw, but in my application just seeing what failed isn't enough to understand what action was being attempted when a failure occurred. Instead I must catch the source error, attach some additional context, and rethrow.
I'd like to be able to attach the original error as a cause
. Spec-level support for this is already underway. A shim has been published as well, but while it can get a cause
property set up correctly, it doesn't contain any logic about rendering causes. This library has an opportunity to be the first to present such information in a useful way and kickstart the community's ability to use this feature.
I'm going to make a fork and see what I can do.
I'm creating a rest api and when in development mode i also return all errors via json as well as logging it to the console. However the prettified stack trace is unreadable when it is returned as a string. Is there a way for me to get the raw stack trace before it was modified?
Example:
"message": "Cannot read property 'dataValues' of null",
"error": " �[0m�[97m�[41mError�[0m�[90m:�[0m�[37m �[0m�[97mCannot read property 'dataValues' of null�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m�[97m�[41mTypeError�[0m�[90m:�[0m�[37m �[0m�[97mCannot read property 'dataVa�[0m\ �[0m �[0m �[0m�[37mlues' of null�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[90m-�[0m �[0m�[93mloginservice.js�[0m�[90m:�[0m�[93m188�[0m�[37m �[0�[0m\ �[0m �[0m �[0m�[37mm�[37mauthenticateUser�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m/home/grimur/Documents/Repos/AuthenticationServer/src/servi�[0m\ �[0m �[0m �[0m�[37mces/loginservice.js:1�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m88:23�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[90m-�[0m �[0m�[93mq.js�[0m�[90m:�[0m�[93m794�[0m�[37m �[0m�[37m_fulf�[0m\ �[0m �[0m �[0m�[37milled�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m[AuthenticationServer]/[q]/q.js:794:54�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[90m-�[0m �[0m�[93mq.js�[0m�[90m:�[0m�[93m823�[0m�[37m �[0m�[37mself.�[0m\ �[0m �[0m �[0m�[37mpromiseDispatch.done�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m[AuthenticationServer]/[q]/q.js:823:30�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[90m-�[0m �[0m�[93mq.js�[0m�[90m:�[0m�[93m756�[0m�[37m �[0m�[37mPromi�[0m\ �[0m �[0m �[0m�[37mse.promise.promiseDispatch�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m[AuthenticationServer]/[q]/q.js:756:13�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[90m-�[0m �[0m�[93mq.js�[0m�[90m:�[0m�[93m564�[0m�[37m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m[AuthenticationServer]/[q]/q.js:564:44�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[90m-�[0m �[0m�[93mq.js�[0m�[90m:�[0m�[93m110�[0m�[37m �[0m�[37mflush�[0m\ �[0m �[0m �[0m�[37m�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m �[0m�[90m[AuthenticationServer]/[q]/q.js:110:17�[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m �[0m�[0m\ �[0m �[0m\ �[0m �[0m�[90m-�[0m �[0m�[37m�[0m�[0m\ �[0m �[0m\ �[0m"
After reinstall the pretty-error module and upgrade renderkid from 0.2.0-beta.10
to 0.2.0-beta.11
, we got the following error.
module.js:340
throw err;
^
Error: Cannot find module './block/config'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/opt/app/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:4:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/opt/app/node_modules/pretty-error/node_modules/renderkid/lib/Layout.js:4:9)
Downgrade the renderkid module solve the problem.
Is there a way to remove \n
between stack trace lines as well as \t
before stack trace line?
I'm going to create and maintain a package thats wraps pretty-error.
You can expect some extra features provided by the package like overriding the console.log
, so you don't have to find and replace everything. Of course, this is a feature that it's disable by default but you enable it.
I'm open to suggestions, feel free to suggest features and improvements.
Hey @AriaMinaei
I am using pretty-error
for the html-webpack-plugin
.
The error is logged to the console and also added to the result html file.
Would it be possible to render the error message also as a html (including a style tag)?
The "bright-white" color does not seem to be working. both in the default theme or if i try to override. The resulting text is always black. Other colors seem to work without issue.
prettyError.appendStyle({
'pretty-error > header > title > kind':{
color: "bright-white"
}
}
originally from: matthewmueller/better-error#1
Because of the nature of skip, it runs a loop from top (latest) line in the stack to the bottom (earilier) line in the stack. This limited control is preventing me from doing something I think is rather simple.
I'd like to specify a file in a stack and get everything from the first call (last instance) up.
So given this stack of addrs.
/Users/thomas/Desktop/node-reggi/delta.js
/Users/thomas/Desktop/node-reggi/gamma..js
/Users/thomas/Desktop/node-reggi/beta.js
/Users/thomas/Desktop/node-reggi/alpha.js
If I specify beta.js
I'd like to skip alpha.js
.
I have this working here.
//skips every addr after `node.js` (from top)
var found = false
pe.skip(function (traceLine) {
var _found = found
var after = 'beta.js'
var pattern = new RegExp(after)
var match = traceLine.path.match(pattern)
if (match) found = true
return _found
})
Where this fails is if beta is called twice in the stack
/Users/thomas/Desktop/node-reggi/delta.js
/Users/thomas/Desktop/node-reggi/gamma..js
/Users/thomas/Desktop/node-reggi/beta.js
/Users/thomas/Desktop/node-reggi/gamma..js
/Users/thomas/Desktop/node-reggi/beta.js
/Users/thomas/Desktop/node-reggi/alpha.js
This function will return
/Users/thomas/Desktop/node-reggi/delta.js
/Users/thomas/Desktop/node-reggi/gamma..js
/Users/thomas/Desktop/node-reggi/beta.js
instead of this, which is my desired result.
/Users/thomas/Desktop/node-reggi/delta.js
/Users/thomas/Desktop/node-reggi/gamma..js
/Users/thomas/Desktop/node-reggi/beta.js
/Users/thomas/Desktop/node-reggi/gamma..js
/Users/thomas/Desktop/node-reggi/beta.js
If there was a skipReverse
function I could do this pretty easily. Is there any way to do this?
Add next_tick.js to the node.js internal packages list
Under production, you normally store your logs into files. if the output is colored then the result is a unreadable output line with ansi codes inside.
Could be great disable colors automatically using the env variable process.env.NODE_END === 'production'
or add a param like {colors: true}
in the .render
and .start
method or in the constructor.
Also related with #16.
I'm looking for a way to pull out the lineNumber
from an error like the one below.
SyntaxError: Unexpected token (210:6)
Can this be done using pretty-error
?
PS. Love the library!
I couldn't figure out a way to turn of line wrapping.
In CSS it would be white-space: nowrap
, but its seems in RenderKid
you are setting a terminal width.
My use case is that I am rendering urls which need to be clickable (using CMD + double-click on OSX). For this reason I cannot have line breaks in between urls.
npm install --save pretty-error 130 ↵
npm WARN deprecated [email protected]: the module is now available as 'css-select'
npm WARN deprecated [email protected]: the module is now available as 'css-what'
$ node
> var PrettyError = require('pretty-error');
undefined
so obviously var pe = new PrettyError();
also returns undefined
and nothing works.
C:\Users\i0x\Desktop\std\ace.js\node_modules\renderkid\lib\renderKid\styles\rule\DeclarationBlock.js:40
this._getDeclarationClass(prop).setOnto(this._declarations, prop, value);
^
[TypeError: this._getDeclarationClass(...).setOnto is not a function]
C:\Users\i0x\Desktop\std\ace.js>node --version
v17.7.2
C:\Users\i0x\Desktop\std\ace.js>yarn --version
1.22.15
"pretty-error": "^4.0.0",
"renderkid": "^3.0.0"
At the moment, CoffeeScript syntax errors get mildly mangled:
Error: unexpected newline
- /Users/ELLIOTTCABLE/Dropbox/Code/Paws/Paws.js/Source/additional.coffee:15:71: er
ror: unexpected newline
- @tput new (require('blessed').Tput) term: process.env['TERM']
- ^
0m
It's not a huge deal, but it's mildly annoying to disable pretty-error
if I need more information about a syntax error.
Could you please make typescript definitions file for pretty-error and send em to DefinitelyTyped project?
It shouldn't be a big deal, just for consistency.
https://github.com/DefinitelyTyped/DefinitelyTyped/
Do you have the changes to this package as they relate to version bumps documented anywhere?
Error: something happened
at test (<anonymous>:1:25)
at <anonymous>:1:47
at EventEmitter.electron.ipcRenderer.on (/Users/sebi/jjd/js_package_nightmare-service/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/init.js:52:28)
at emitMany (events.js:127:13)
at EventEmitter.emit (events.js:201:7)
Error: something happened
<anonymous>:1 test <anonymous>:1:25
<anonymous>:1 <anonymous>:1:47
In an attempt to keep unnecessary package creep from happening, it would be very nice if there were two versions or a plugin architecture where we could depend on a version that included or did not included web/browser based rendering.
Some of the dependencies (22 packages in total once flattened; including pretty-error) are not at all needed in a server only environment.
Not sure if paths changed since previous Node versions, or if this method was only intended to include specific files but it doesn't seem to be working the way I would expect this to work.
For example, I would consider the internal/modules/cjs/loader.js
file to be a Node file since I didn't create it but even when I set up this basic script, the trace still shows that file:
const PrettyError = require('pretty-error');
const pe = new PrettyError();
pe.skipNodeFiles();
pe.start();
console.log(processs.cwd()) // misspelled to cause error
[ ReferenceError: processs is not defined
- server.js:35 Object.<anonymous>
[project]/server-express/server.js:35:13
- loader.js:1063 Module._compile
internal/modules/cjs/loader.js:1063:30
- loader.js:1092 Object.Module._extensions..js
internal/modules/cjs/loader.js:1092:10
- loader.js:928 Module.load
internal/modules/cjs/loader.js:928:32
- loader.js:769 Function.Module._load
internal/modules/cjs/loader.js:769:14
- loader.js:952 Module.require
internal/modules/cjs/loader.js:952:19
- helpers.js:88 require
internal/modules/cjs/helpers.js:88:18
- www:7 Object.<anonymous>
./bin/www:7:13
- loader.js:1063 Module._compile
internal/modules/cjs/loader.js:1063:30
- loader.js:1092 Object.Module._extensions..js
internal/modules/cjs/loader.js:1092:10
]
I'm pretty sure that this is because the nodePaths.coffee
references exact filenames, and the relevant code is just using indexOf to check if the stack path is a "Node" file.
I'll add that I'm making a lot of assumptions here, so apologies if I'm misunderstanding the skipNodeFiles
method or anything else.
Thanks for all the work on the project so far!
Filtering is very useful to cleanup the stacktrace.
However often the stacktrace could be strange to read especially when there are anonymous entries. It would be nice if there were an option to mark filtered entries so the filtered line could be outputed also but style with render kid as less important entry. Of course this makes only sense in color output mode.
I'm getting a console warning when requiring the module:
sys is deprecated. Use util instead.
and when try to prettify an error, I got this exception:
/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/SpecialString.js:18
if (this.constructor !== self) {
^
TypeError: Cannot read property 'constructor' of undefined
at SpecialString (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/SpecialString.js:16:13)
at Block.module.exports.Block._writeInline (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:196:9)
at Block.module.exports.Block._flushBuffer (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:165:10)
at Block.module.exports.Block._deactivate (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:93:10)
at Block.module.exports.Block._activate (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:82:22)
at Block.module.exports.Block._open (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:123:10)
at Block.module.exports.Block.openBlock (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/layout/Block.js:154:11)
at RenderKid.module.exports.RenderKid._renderBlockNode (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/RenderKid.js:149:25)
at RenderKid.module.exports.RenderKid._renderNode (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/RenderKid.js:124:12)
at RenderKid.module.exports.RenderKid._renderChildrenOf (/mnt/repositories/repositories/termite-modules/she/node_modules/pretty-error/node_modules/renderkid/lib/RenderKid.js:114:12)
"Error\u001b[0m:\u001b[0m \u001b[0mSome error message\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m Object.<anonymous>\u001b[0m (/Users/thomas/Desktop/node-reggi/z-multi-line.js:89:9)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m Module._compile\u001b[0m (module.js:430:26)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m Object.Module._extensions..js\u001b[0m (module.js:448:10)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m Module.load\u001b[0m (module.js:355:32)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m Function.Module._load\u001b[0m (module.js:310:12)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m Function.Module.runMain\u001b[0m (module.js:471:10)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m startup\u001b[0m (node.js:117:18)\u001b[0m\n\u001b[0m \u001b[0mat\u001b[0m \u001b[0mnode.js:953:3\u001b[0m\n\u001b[0m"
I can use chalk.stripColor(string) to remove them. Didn't expect ansi codes when color wasn't applied.
Just noticed there aren't any tests. How do you make sure it works when you are making changes?
/home/travis/build/project-x/auth/node_modules/pretty-error/lib/ParsedError.js:23
this._stack = this.error.stack;
^
Error: `from` shouldn't be larger than `to`
This happened when I ran render(error)
for an error that mongodb throws using their native driver while creating indexes. I could not figure out exactly what the error was but render
was the culprit.
In my append style I have the trace
for what
and footer > addr
both set to marginLeft:1
.
'pretty-error >
trace > item > header > what': _.defaults({
marginLeft: 1
}, nullStyle),
'pretty-error > trace > item > footer': _.defaults({
}, nullStyle),
'pretty-error > trace > item > footer > addr': _.defaults({
marginLeft: 1
}, nullStyle),
You can see the last line in the trace doesn't have a what
element.
{
"item": {
"header": {
"pointer": {
"file": "node.js",
"colon": ":",
"line": 953
},
"what": null
},
"footer": {
"addr": "node.js:953:3"
}
}
}
However the on last line, after the bullet there are two spaces instead of one.
Error: Some error message
at Object.<anonymous> /Users/thomas/Desktop/node-reggi/z-multi-line.js:57:9
at Module._compile module.js:430:26
at Object.Module._extensions..js module.js:448:10
at Module.load module.js:355:32
at Function.Module._load module.js:310:12
at Function.Module.runMain module.js:471:10
at startup node.js:117:18
at node.js:953:3
This is unexpected behavior. Without both of these margins set there is no space after the at
bullet.
I simply want to output:
Error: Some error message
at Object.<anonymous> /Users/thomas/Desktop/node-reggi/z-multi-line.js:57:9
at Module._compile module.js:430:26
at Object.Module._extensions..js module.js:448:10
at Module.load module.js:355:32
at Function.Module._load module.js:310:12
at Function.Module.runMain module.js:471:10
at startup node.js:117:18
at node.js:953:3
I'm thinking about making a patch and curious about unusual coding style i'm seeing. There are a lot of blank lines. Wondering if this is intentional or a side effect of the editor you are using?
the link on the readme is broke :/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.