1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:17:35 +00:00
serenity/Userland/Libraries/LibJS/Runtime/Exception.h
Linus Groh 97d49cb92b LibJS: Consolidate exception function names and source ranges
Instead of storing the function names (in a badly named Vector<String>)
and source ranges separately, consolidate them into a new struct:
TracebackFrame. This makes it both easier to use now and easier to
extend in the future.
Unlike before we now keep each call frame's current node source range
in the traceback frame next to the function name, meaning we can display
line and column numbers outside of the VM and after the call stack is
emptied.
2021-04-24 20:11:04 +02:00

39 lines
867 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Linus Groh <mail@linusgroh.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <AK/Vector.h>
#include <LibJS/Runtime/Cell.h>
#include <LibJS/Runtime/Value.h>
#include <LibJS/SourceRange.h>
namespace JS {
struct TracebackFrame {
FlyString function_name;
SourceRange source_range;
};
class Exception : public Cell {
public:
explicit Exception(Value);
virtual ~Exception() override = default;
Value value() const { return m_value; }
const Vector<TracebackFrame>& traceback() const { return m_traceback; }
private:
virtual const char* class_name() const override { return "Exception"; }
virtual void visit_edges(Visitor&) override;
Value m_value;
Vector<TracebackFrame> m_traceback;
};
}