torbenrudgaard
torbenrudgaard

Reputation: 2561

How to get the line no or file name of js errors?

I am getting a bit tired of errors like these:

enter image description here

It says nothing about what file or what function or what line.

In this case this was the caller line

vm.setDates(new Date(vm.checkin*1000).format('M d Y'), new Date(vm.checkout*1000).format('M d Y'))

And a few functions down in the code was the .format function where the error was..

Is there any way to get better "error directions" than app.bundle.js:12345 ??

Upvotes: 5

Views: 511

Answers (1)

Eduardo Melo
Eduardo Melo

Reputation: 519

I think you should use sourcemaps. A sourcemap is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of sourcemaps is to aid debugging. Basically, if there’s an error in the generated code file, the map can tell you the original source file location. Reference: Sourcemaps.

Upvotes: 1

Related Questions