Return the line number and filename of failing line from given error object
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.npmignore
README.md
example.js
index.js
package.json
test.js

README.md

failing-line

Return the line and column number, filename and function name from the failing line from given error object.

Install

$ npm install failing-line

Usage

var failingLine = require('failing-line')

process.on('uncaughtException', function (error) {
  failingLine(error)
  // => { line: 8, col: 0, function: 'Object.<anonymous>' filename: 'example.js' }
})

hereIfail++

If the top line(s) in the stack should be skipped in your case, pass an extra parameter:

failingLine(error, 1) // will start reading stack from second line

Check out test.js for more info.