Answers for "javascript get line number of error"

1

javascript get line number of error

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

var err = getErrorObject();
var caller_line = err.stack.split("\n")[4];
var index = caller_line.indexOf("at ");
var clean = caller_line.slice(index+2, caller_line.length);
Posted by: Guest on June-22-2020

Code answers related to "javascript get line number of error"

Code answers related to "Javascript"

Browse Popular Code Answers by Language