0

I am trying to throw an error to the Javascript console using console.error(), and I would like to set the line number so people can see where they went wrong. Is this at all possible?

Thanks in advance,

Awesomeness01

Awesomeness01
  • 2,321
  • 1
  • 18
  • 17
  • 2
    Um, why are you not using [`throw`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/throw)? – epascarello Jan 06 '15 at 00:44

1 Answers1

0

Use throw isntead console.error:

throw "Error Message";

console.error just prints out a red message to the browser dev tools and throw raises an exception in the current code block which will give all properties that an exception has (stack trace, line number, etc).

ianaya89
  • 4,153
  • 3
  • 26
  • 34