From d89990951ee2a8d90707f012cefba0e4067a3a7f Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Fri, 16 Aug 2019 22:18:13 -0600 Subject: [PATCH] Convert panic to error when calling emscripten main --- lib/emscripten/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/emscripten/src/lib.rs b/lib/emscripten/src/lib.rs index c37e34d8e34..2f03dbb3b6e 100644 --- a/lib/emscripten/src/lib.rs +++ b/lib/emscripten/src/lib.rs @@ -16,7 +16,7 @@ use std::collections::HashMap; use std::path::PathBuf; use std::{f64, ffi::c_void}; use wasmer_runtime_core::{ - error::CallResult, + error::{CallError, CallResult, ResolveError}, export::Export, func, global::Global, @@ -373,10 +373,11 @@ pub fn run_emscripten_instance( 0 => { instance.call(func_name, &[])?; } - _ => panic!( - "The emscripten main function has received an incorrect number of params {}", - num_params - ), + _ => { + return Err(CallError::Resolve(ResolveError::ExportWrongType { + name: "main".to_string(), + })) + } }; }