Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript get line number of error

function getErrorObject(){
    try { throw Error('') } catch(err) { return err; }
}

var err = getErrorObject();
var caller_line = err.stack.split("
")[4];
var index = caller_line.indexOf("at ");
var clean = caller_line.slice(index+2, caller_line.length);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #line #number #error
ADD COMMENT
Topic
Name
2+9 =