mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00
LibJS: Track source positions all the way down to exceptions
This makes exceptions have a trace of source positions too, which could probably be helpful in making fancier error tracebacks.
This commit is contained in:
parent
f17874ecd2
commit
b34b681811
10 changed files with 647 additions and 245 deletions
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Runtime/Exception.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
|
||||
|
@ -40,6 +41,13 @@ Exception::Exception(Value value)
|
|||
function_name = "<anonymous>";
|
||||
m_trace.append(function_name);
|
||||
}
|
||||
|
||||
auto& node_stack = vm().node_stack();
|
||||
for (ssize_t i = node_stack.size() - 1; i >= 0; --i) {
|
||||
auto* node = node_stack[i];
|
||||
ASSERT(node);
|
||||
m_source_ranges.append(node->source_range());
|
||||
}
|
||||
}
|
||||
|
||||
Exception::~Exception()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue