浏览代码

js: Improve usage of `TRY` when executing a file program

James Puleo 3 年之前
父节点
当前提交
dd25dfbc20
共有 1 个文件被更改,包括 1 次插入5 次删除
  1. 1 5
      Userland/Utilities/js.cpp

+ 1 - 5
Userland/Utilities/js.cpp

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