mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-25 20:31:58 +00:00
Rethrow exceptions from the top level of a module
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
#include "scriptinterface/ScriptTypes.h"
|
||||
|
||||
#include <exception>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
|
||||
@@ -49,10 +50,15 @@ public:
|
||||
struct Evaluating
|
||||
{
|
||||
JS::PersistentRootedObject fulfill;
|
||||
JS::PersistentRootedObject reject;
|
||||
};
|
||||
struct Fulfilled {};
|
||||
struct Rejected
|
||||
{
|
||||
std::exception_ptr error;
|
||||
};
|
||||
struct Invalid {};
|
||||
using Status = std::variant<Evaluating, Fulfilled, Invalid>;
|
||||
using Status = std::variant<Evaluating, Fulfilled, Rejected, Invalid>;
|
||||
|
||||
explicit Future(const ScriptRequest& rq, ModuleLoader& loader, const VfsPath& modulePath);
|
||||
Future() = default;
|
||||
@@ -64,6 +70,11 @@ public:
|
||||
|
||||
[[nodiscard]] bool IsDone() const noexcept;
|
||||
|
||||
/**
|
||||
* Throws if the evaluation of the module failed.
|
||||
*/
|
||||
void Get();
|
||||
|
||||
private:
|
||||
// It's save to not require a `JS::HandleValue` here.
|
||||
void SetReservedSlot(JS::Value privateValue) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user