mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:07:34 +00:00
LibCore: Use ErrorOr<T> for Core::File::open()
This commit is contained in:
parent
fac2550143
commit
a7f1f1c34b
24 changed files with 42 additions and 48 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <LibTest/JavaScriptTestRunner.h>
|
||||
#include <LibWasm/AbstractMachine/BytecodeInterpreter.h>
|
||||
#include <LibWasm/Types.h>
|
||||
#include <string.h>
|
||||
|
||||
TEST_ROOT("Userland/Libraries/LibWasm/Tests");
|
||||
|
||||
|
@ -16,7 +17,7 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile)
|
|||
auto filename = TRY(vm.argument(0).to_string(global_object));
|
||||
auto file = Core::File::open(filename, Core::OpenMode::ReadOnly);
|
||||
if (file.is_error())
|
||||
return vm.throw_completion<JS::TypeError>(global_object, file.error().string());
|
||||
return vm.throw_completion<JS::TypeError>(global_object, strerror(file.error().code()));
|
||||
auto contents = file.value()->read_all();
|
||||
auto array = JS::Uint8Array::create(global_object, contents.size());
|
||||
contents.span().copy_to(array->data());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue