summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bindings.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index 7fb8aac70..23cd86a17 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -315,16 +315,19 @@ fn print(
_rv: v8::ReturnValue,
) {
let arg_len = args.length();
- assert!((0..=2).contains(&arg_len));
+ if !(0..=2).contains(&arg_len) {
+ return throw_type_error(scope, "Expected a maximum of 2 arguments.");
+ }
let obj = args.get(0);
let is_err_arg = args.get(1);
let mut is_err = false;
if arg_len == 2 {
- let int_val = is_err_arg
- .integer_value(scope)
- .expect("Unable to convert to integer");
+ let int_val = match is_err_arg.integer_value(scope) {
+ Some(v) => v,
+ None => return throw_type_error(scope, "Invalid arugment. Argument 2 should indicate wheter or not to print to stderr."),
+ };
is_err = int_val != 0;
};
let tc_scope = &mut v8::TryCatch::new(scope);