blob: d4069a991ca63744e6ef9f21042c216c73fc4f2f (
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
|
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/Exception.h>
#include <LibJS/Runtime/VM.h>
namespace JS {
class TemporaryClearException {
public:
explicit TemporaryClearException(VM& vm)
: m_vm(vm)
, m_previous_exception(vm.exception())
{
m_vm.clear_exception();
}
~TemporaryClearException()
{
if (m_previous_exception)
m_vm.set_exception(*m_previous_exception);
}
private:
VM& m_vm;
Exception* m_previous_exception;
};
}
|