Browse Source

remove duplicate error augment calls

pull/1/head
Sami Vaarala 12 years ago
parent
commit
49c3585ed5
  1. 24
      src/duk_builtin_duk.c
  2. 19
      src/duk_error_throw.c

24
src/duk_builtin_duk.c

@ -187,16 +187,11 @@ int duk_builtin_duk_object_resume(duk_context *ctx) {
}
/*
* The error object could conceivably contain either the resumer
* or the resumee callstack. Here we use the resumee's callstack
* which is more logical for code catching the error in the resumee.
* The error object has been augmented with a traceback and other
* info from its creation point -- usually another thread. It might
* be nice to get a traceback from the resumee but this is not the
* case now.
*/
#ifdef DUK_USE_AUGMENT_ERRORS
if (is_error) {
/* Note: may throw an error */
duk_err_augment_error(thr, thr_resume, 1);
}
#endif
#ifdef DUK_USE_DEBUG /* debug logging */
if (is_error) {
@ -306,16 +301,9 @@ int duk_builtin_duk_object_yield(duk_context *ctx) {
}
/*
* The error object could conceivably contain either the yielder
* or the resumer callstack. Here we use the resumer's callstack.
* The error object has been augmented with a traceback and other
* info from its creation point -- usually the current thread.
*/
#ifdef DUK_USE_AUGMENT_ERRORS
if (is_error) {
/* Note: may throw an error */
DUK_ASSERT(thr->resumer != NULL);
duk_err_augment_error(thr, thr->resumer, 0);
}
#endif
#ifdef DUK_USE_DEBUG
if (is_error) {

19
src/duk_error_throw.c

@ -134,7 +134,7 @@ void duk_err_create_and_throw(duk_hthread *thr, duk_u32 code) {
duk_push_int(ctx, code);
}
} else {
/* FIXME: who sets which properties? */
/* Error object is augmented at its creation here. */
#ifdef DUK_USE_VERBOSE_ERRORS
duk_push_new_error_object(ctx, code, msg);
#else
@ -155,23 +155,6 @@ void duk_err_create_and_throw(duk_hthread *thr, duk_u32 code) {
call_errhandler(thr);
}
/*
* Augment the error (potentially), e.g. with a traceback
*
* Errors should be augmented when they are created, not when they
* are thrown. However, because we create and throw the error, we
* augment it here, unless it is a "double error".
*/
#ifdef DUK_USE_AUGMENT_ERRORS
if (double_error || code == DUK_ERR_ALLOC_ERROR) {
DUK_DPRINT("alloc or double error: skip adding traceback");
} else {
/* may throw an error */
duk_err_augment_error(thr, thr, -1);
}
#endif
/*
* Finally, longjmp
*/

Loading…
Cancel
Save