mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
LibJS: Add a traceback to Error
Since we have the traceback we now also generate the stack string on demand instead of immediately on construction.
This commit is contained in:
parent
f324d91106
commit
e160f508a8
3 changed files with 39 additions and 18 deletions
|
@ -10,9 +10,15 @@
|
|||
#include <AK/FlyString.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/SourceRange.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
struct TracebackFrame {
|
||||
FlyString function_name;
|
||||
SourceRange source_range;
|
||||
};
|
||||
|
||||
class Error : public Object {
|
||||
JS_OBJECT(Error, Object);
|
||||
|
||||
|
@ -23,13 +29,15 @@ public:
|
|||
explicit Error(Object& prototype);
|
||||
virtual ~Error() override = default;
|
||||
|
||||
String const& stack_string() const { return m_stack_string; }
|
||||
[[nodiscard]] String stack_string() const;
|
||||
|
||||
ThrowCompletionOr<void> install_error_cause(Value options);
|
||||
|
||||
Vector<TracebackFrame, 32> const& traceback() const { return m_traceback; }
|
||||
|
||||
private:
|
||||
void populate_stack();
|
||||
String m_stack_string {};
|
||||
Vector<TracebackFrame, 32> m_traceback;
|
||||
};
|
||||
|
||||
// NOTE: Making these inherit from Error is not required by the spec but
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue