mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibJS: Make ASTNode::generate_bytecode() fallible
Instead of crashing on the spot, return a descriptive error that will eventually continue its days as a javascript "InternalError" exception. This should make random crashes with BC less likely.
This commit is contained in:
parent
3a5f7cb524
commit
75aa900b83
10 changed files with 378 additions and 233 deletions
25
Userland/Libraries/LibJS/Bytecode/CodeGenerationError.h
Normal file
25
Userland/Libraries/LibJS/Bytecode/CodeGenerationError.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
struct CodeGenerationError {
|
||||
ASTNode const* failing_node { nullptr };
|
||||
StringView reason_literal;
|
||||
|
||||
String to_string();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
using CodeGenerationErrorOr = ErrorOr<T, CodeGenerationError>;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue