ladybird/Userland/Libraries/LibWeb/HTML/Scripting/ExceptionReporter.h
Pavel 40aad77ab1 WebContent+LibWeb+LibJS: Report exceptions to the JS console
Print exceptions passed to `HTML::report_exception` in the JS console

Refactored `ExceptionReporter`: in order to report exception now
you need to pass the relevant realm in it. For passed `JS::Value`
we now create `JS::Error` object to print value as the error message.
2022-10-15 01:25:12 +02:00

29 lines
570 B
C++

/*
* Copyright (c) 2022, David Tuin <davidot@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Forward.h>
namespace Web::HTML {
enum class ErrorInPromise {
No,
Yes,
};
void report_exception_to_console(JS::Value, JS::Realm&, ErrorInPromise);
void report_exception(JS::Completion const&, JS::Realm&);
template<typename T>
inline void report_exception(JS::ThrowCompletionOr<T> const& result, JS::Realm& realm)
{
VERIFY(result.is_throw_completion());
report_exception(result.throw_completion(), realm);
}
}