1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 21:05:06 +00:00

js: Improve usage of TRY when executing a file program

This commit is contained in:
James Puleo 2021-12-08 19:33:41 -05:00 committed by Brian Gianforcaro
parent 859b810db1
commit dd25dfbc20

View file

@ -1493,11 +1493,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
StringBuilder builder; StringBuilder builder;
for (auto& path : script_paths) { for (auto& path : script_paths) {
auto file = Core::File::construct(path); auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly));
if (!file->open(Core::OpenMode::ReadOnly)) {
warnln("Failed to open {}: {}", path, file->error_string());
return 1;
}
auto file_contents = file->read_all(); auto file_contents = file->read_all();
auto source = StringView { file_contents }; auto source = StringView { file_contents };
builder.append(source); builder.append(source);