Skip to content

Commit 3b02753

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 3b02753

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
@@ -143,14 +143,14 @@ impl UninitializedSandbox {
143143
log_build_details();
144144

145145
// If the guest binary is a file make sure it exists
146-
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)