1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:37:35 +00:00

LibJS+Embedders: Unify stack trace format for uncaught errors

Previously these handlers duplicated code and used formats that
were different from the one Error.prototype.stack uses.

Now they use the same Error::stack_string function, which accepts
a new parameter for compacting stack traces with repeating frames.
This commit is contained in:
Simon Wanner 2023-10-31 21:55:17 +01:00 committed by Andreas Kling
parent 2fb0cede9a
commit 93908fcbcb
6 changed files with 52 additions and 78 deletions

View file

@ -72,11 +72,7 @@ Sheet::Sheet(Workbook& workbook)
if (thrown_value.is_object() && is<JS::Error>(thrown_value.as_object())) {
auto& error = static_cast<JS::Error const&>(thrown_value.as_object());
warnln(" with message '{}'", error.get_without_side_effects(vm.names.message));
for (auto& traceback_frame : error.traceback()) {
auto& function_name = traceback_frame.function_name;
auto& source_range = traceback_frame.source_range();
dbgln(" {} at {}:{}:{}", function_name, source_range.filename(), source_range.start.line, source_range.start.column);
}
dbgln("{}", error.stack_string(JS::CompactTraceback::Yes));
} else {
warnln();
}