diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2021-05-28 20:14:27 +0300 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2021-06-10 09:45:28 +0300 |
commit | 8834ec9f5c522f7d800d85b245a9806418515b7c (patch) | |
tree | 7f8719dd7d49df73be15b31d958636b433ed36d6 /src/util.h | |
parent | c109a6cc830146f90c31f608d24c2afa22335364 (diff) |
src: throw error in LoadBuiltinModuleSource when reading fails
- Move the file reading code in LoadBuiltinModuleSource into
util.h so that it can be reused by other C++ code, and
return an error code from it when there is a failure for
the caller to generate an error.
- Throw an error when reading local builtins fails in
LoadBulitinModuleSource.
PR-URL: https://github.com/nodejs/node/pull/38904
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h index 79ad3dfe2d0..050e4bda35a 100644 --- a/src/util.h +++ b/src/util.h @@ -813,6 +813,10 @@ std::unique_ptr<T> static_unique_pointer_cast(std::unique_ptr<U>&& ptr) { } #define MAYBE_FIELD_PTR(ptr, field) ptr == nullptr ? nullptr : &(ptr->field) + +// Returns a non-zero code if it fails to open or read the file, +// aborts if it fails to close the file. +int ReadFileSync(std::string* result, const char* path); } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |