23andreas
23andreas

Reputation: 1

Bluebird async.js throws error

When I debug my application and set it to breakpoint on all exceptions, it stops at line 3 in bluebirds async.js (link)

{throw new Error(); } catch (e) {firstLineError = e;}

That line strikes me as a little odd.

What's the purpose of it?

Thank you

Upvotes: 0

Views: 290

Answers (1)

rsp
rsp

Reputation: 111316

I would assume that it is there to get the error object of the first line to have some info about file names, paths and line numbers because things like this can be used for that. But I would have to look at the source code. It certainly looks interesting.

This is used in src/debuggability.js in the setBounds() function:

that is called in this string that contains JavaScript which is presumably evaled somewhere:

This string is stored in a variable called lastLineCode. It seems that this all sets some scope for debugging to make sure that what is debugged is between the first line and the last line of the relevant part of the Bluebird source code, e.g. when it is combined with other modules.

You can look at some of those commits for more context of how it was added:

Upvotes: 1

Related Questions