summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Exception.h
blob: 885bb91105670f0fe4024ca3aba89b629cf3f5a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/FlyString.h>
#include <AK/Vector.h>
#include <LibJS/Heap/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;
};

}