Skip to content

Commit 64bfcb6

Browse files
stlankesvalopok
authored andcommitted
add check if a wasm module is specified
1 parent 49d168a commit 64bfcb6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

examples/hermit-wasm/src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,15 @@ pub fn main() -> Result<()> {
4444
// Currently, we are using the default configuration.
4545
let config = wasmtime::Config::new();
4646

47-
info!("Start Hermit-WASM!");
47+
if CONFIG.module_and_args.is_empty() {
48+
eprintln!("No WebAssembly module specified. Please provide a .wacdsm file to run.");
49+
std::process::exit(1);
50+
}
51+
let fname = CONFIG.module_and_args[0].clone();
52+
info!("Start Hermit-WASM: {fname:?}");
4853

4954
let mut buffer = Vec::new();
50-
let mut f = File::open(CONFIG.module_and_args[0].clone()).expect("Unable to open wasm module");
55+
let mut f = File::open(fname).expect("Unable to open wasm module");
5156

5257
f.read_to_end(&mut buffer)?;
5358

0 commit comments

Comments
 (0)