Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
E.Azer Koçulu
committed
Mar 13, 2014
0 parents
commit 0b059ff
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test | ||
test.js | ||
example | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## failing-line | ||
|
||
Return the line number and filename of failing line from given error object | ||
|
||
## Install | ||
|
||
```bash | ||
$ npm install failing-line | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
var failingLine = require('failing-line') | ||
|
||
process.on('uncaughtException', function (error) { | ||
failingLine(error) | ||
// => { lineno: 8, filename: 'example.js' } | ||
}) | ||
|
||
hereIfail++ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = failingLine; | ||
|
||
function failingLine (error) { | ||
var match = error.stack.match(/\(([^\(\)]+)\)/); | ||
if (!match) return undefined; | ||
|
||
match = match[1].split(':'); | ||
|
||
return { | ||
filename: match[0], | ||
lineno: Number(match[1]) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "failing-line", | ||
"version": "0.0.0", | ||
"description": "Return the line number and filename of failing line from given error object", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"devDependencies": { | ||
"tape": "*" | ||
}, | ||
"keywords": [ | ||
"error", | ||
"fail", | ||
"failing", | ||
"line number" | ||
], | ||
"repository": { | ||
"url": "git@github.com:azer\/failing-line.git", | ||
"type": "git" | ||
}, | ||
"author": "azer", | ||
"license": "BSD" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var failingLine = require("./"); | ||
var test = require("tape"); | ||
|
||
test('failing line', function (assert) { | ||
var err = new Error('Hello World'); | ||
var ln = failingLine(err); | ||
|
||
assert.equal(ln.lineno, 5); | ||
assert.equal(ln.filename, __filename); | ||
assert.end(); | ||
}); |