Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from skimcom/master

captureStackTrace if error object is passed but err.stack is undefined
  • Loading branch information...
commit c2a20d7ff9afc72d72554aedf4429c5f54feba84 2 parents 87732f0 + 6cca37b
@chrisdickinson authored
Showing with 7 additions and 6 deletions.
  1. +1 −1  package.json
  2. +6 −5 trace.js
View
2  package.json
@@ -2,7 +2,7 @@
"author": "Chris Dickinson <chris@neversaw.us> (http://neversaw.us/)",
"name": "tracejs",
"description": "Expand Error.stack traces into usable objects providing context and highlighting",
- "version": "0.1.4",
+ "version": "0.1.5",
"homepage": "http://github.com/chrisdickinson/tracejs/",
"repository": {
"type": "git",
View
11 trace.js
@@ -152,7 +152,7 @@ Frame.prototype.toString = function() {
};
Frame.prototype.get_lines = function(context, ascii_cursor, highlight_error_start) {
- context = context || 0;
+ context = context || 0;
filedata = this.filedata().split('\n');
var start_line = this.line - context - 1,
@@ -194,10 +194,11 @@ Frame.prototype.get_lines = function(context, ascii_cursor, highlight_error_star
return lines.join('\n');
};
-var trace = function(err) {
- if(!err) {
- err = {};
- Error.captureStackTrace(err);
+var trace = function trace(err) {
+ err || (err = {});
+
+ if (!err.stack) {
+ Error.captureStackTrace(err, trace);
}
var lines = err.stack.split('\n'),
Please sign in to comment.
Something went wrong with that request. Please try again.