Skip to content

Commit 996c8ae

Browse files
committed
Improve error when file not found, and avoid unnecessary call to try_exists, and fix unnecessary recreation of matched pattern
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 94512d8 commit 996c8ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/hyperlight_host/src/sandbox/uninitialized.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ impl UninitializedSandbox {
141141
host_print_writer: Option<&dyn HostFunction1<String, i32>>,
142142
) -> Result<Self> {
143143
log_build_details();
144-
145144
// If the guest binary is a file make sure it exists
146145

147146
let guest_binary = match guest_binary {
148147
GuestBinary::FilePath(binary_path) => {
149-
let path = Path::new(&binary_path).canonicalize()?;
150-
path.try_exists()?;
148+
let path = Path::new(&binary_path)
149+
.canonicalize()
150+
.map_err(|e| new_error!("GuestBinary not found: '{}': {}", binary_path, e))?;
151151
GuestBinary::FilePath(path.to_str().unwrap().to_string())
152152
}
153-
GuestBinary::Buffer(buffer) => GuestBinary::Buffer(buffer),
153+
buffer @ GuestBinary::Buffer(_) => buffer,
154154
};
155155

156156
let run_opts = sandbox_run_options.unwrap_or_default();

0 commit comments

Comments
 (0)