Browse Source

Paranoid error message for call handling

Also handle config option rename.
pull/417/head
Sami Vaarala 9 years ago
parent
commit
8717df276f
  1. 24
      src/duk_hobject_props.c
  2. 5
      src/duk_js_call.c

24
src/duk_hobject_props.c

@ -2247,11 +2247,11 @@ DUK_INTERNAL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj,
case DUK_TAG_NULL: {
/* Note: unconditional throw */
DUK_DDD(DUK_DDDPRINT("base object is undefined or null -> reject"));
#if defined(DUK_USE_VERBOSE_PROP_ERRORS)
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "cannot read property %s of %s",
duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#endif
return 0;
}
@ -3287,11 +3287,11 @@ DUK_INTERNAL duk_bool_t duk_hobject_putprop(duk_hthread *thr, duk_tval *tv_obj,
/* Note: unconditional throw */
DUK_DDD(DUK_DDDPRINT("base object is undefined or null -> reject (object=%!iT)",
(duk_tval *) tv_obj));
#if defined(DUK_USE_VERBOSE_PROP_ERRORS)
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s",
duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#endif
return 0;
}
@ -4049,11 +4049,11 @@ DUK_INTERNAL duk_bool_t duk_hobject_putprop(duk_hthread *thr, duk_tval *tv_obj,
fail_base_primitive:
DUK_DDD(DUK_DDDPRINT("result: error, base primitive"));
if (throw_flag) {
#if defined(DUK_USE_VERBOSE_PROP_ERRORS)
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "cannot write property %s of %s",
duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#endif
}
duk_pop(ctx); /* remove key */
@ -4416,11 +4416,11 @@ DUK_INTERNAL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj,
fail_invalid_base_uncond:
/* Note: unconditional throw */
DUK_ASSERT(duk_get_top(ctx) == entry_top);
#if defined(DUK_USE_VERBOSE_PROP_ERRORS)
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "cannot delete property %s of %s",
duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_BASE);
#endif
return 0;

5
src/duk_js_call.c

@ -715,7 +715,12 @@ duk_hobject *duk__nonbound_func_lookup(duk_context *ctx,
return func;
not_callable_error:
DUK_ASSERT(tv_func != NULL);
#if defined(DUK_USE_PARANOID_ERRORS)
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, DUK_STR_NOT_CALLABLE);
#else
DUK_ERROR(thr, DUK_ERR_TYPE_ERROR, "%s not callable", duk_push_string_tval_readable(ctx, tv_func));
#endif
DUK_UNREACHABLE();
return NULL; /* never executed */
}

Loading…
Cancel
Save