|
|
@ -9,7 +9,7 @@ |
|
|
|
#ifdef DUK_USE_VERBOSE_ERRORS |
|
|
|
|
|
|
|
#ifdef DUK_USE_VARIADIC_MACROS |
|
|
|
void duk_err_handle_error(const char *filename, int line, duk_hthread *thr, int code, const char *fmt, ...) { |
|
|
|
void duk_err_handle_error(const char *filename, duk_int_t line, duk_hthread *thr, duk_errcode_t code, const char *fmt, ...) { |
|
|
|
va_list ap; |
|
|
|
char msg[DUK__ERRFMT_BUFSIZE]; |
|
|
|
va_start(ap, fmt); |
|
|
@ -20,25 +20,25 @@ void duk_err_handle_error(const char *filename, int line, duk_hthread *thr, int |
|
|
|
} |
|
|
|
#else /* DUK_USE_VARIADIC_MACROS */ |
|
|
|
const char *duk_err_file_stash = NULL; |
|
|
|
int duk_err_line_stash = 0; |
|
|
|
duk_int_t duk_err_line_stash = 0; |
|
|
|
|
|
|
|
DUK_NORETURN(static void duk__handle_error(const char *filename, int line, duk_hthread *thr, int code, const char *fmt, va_list ap)); |
|
|
|
DUK_NORETURN(static void duk__handle_error(const char *filename, duk_int_t line, duk_hthread *thr, duk_errcode_t code, const char *fmt, va_list ap)); |
|
|
|
|
|
|
|
static void duk__handle_error(const char *filename, int line, duk_hthread *thr, int code, const char *fmt, va_list ap) { |
|
|
|
static void duk__handle_error(const char *filename, duk_int_t line, duk_hthread *thr, duk_errcode_t code, const char *fmt, va_list ap) { |
|
|
|
char msg[DUK__ERRFMT_BUFSIZE]; |
|
|
|
(void) DUK_VSNPRINTF(msg, sizeof(msg), fmt, ap); |
|
|
|
msg[sizeof(msg) - 1] = (char) 0; |
|
|
|
duk_err_create_and_throw(thr, code, msg, filename, line); |
|
|
|
} |
|
|
|
|
|
|
|
void duk_err_handle_error(const char *filename, int line, duk_hthread *thr, int code, const char *fmt, ...) { |
|
|
|
void duk_err_handle_error(const char *filename, duk_int_t line, duk_hthread *thr, duk_errcode_t code, const char *fmt, ...) { |
|
|
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
|
|
duk__handle_error(filename, line, thr, code, fmt, ap); |
|
|
|
va_end(ap); /* dead code */ |
|
|
|
} |
|
|
|
|
|
|
|
void duk_err_handle_error_stash(duk_hthread *thr, int code, const char *fmt, ...) { |
|
|
|
void duk_err_handle_error_stash(duk_hthread *thr, duk_errcode_t code, const char *fmt, ...) { |
|
|
|
va_list ap; |
|
|
|
va_start(ap, fmt); |
|
|
|
duk__handle_error(duk_err_file_stash, duk_err_line_stash, thr, code, fmt, ap); |
|
|
@ -49,16 +49,16 @@ void duk_err_handle_error_stash(duk_hthread *thr, int code, const char *fmt, ... |
|
|
|
#else /* DUK_USE_VERBOSE_ERRORS */ |
|
|
|
|
|
|
|
#ifdef DUK_USE_VARIADIC_MACROS |
|
|
|
void duk_err_handle_error(duk_hthread *thr, int code) { |
|
|
|
void duk_err_handle_error(duk_hthread *thr, duk_errcode_t code) { |
|
|
|
duk_err_create_and_throw(thr, code); |
|
|
|
} |
|
|
|
|
|
|
|
#else /* DUK_USE_VARIADIC_MACROS */ |
|
|
|
void duk_err_handle_error_nonverbose1(duk_hthread *thr, int code, const char *fmt, ...) { |
|
|
|
void duk_err_handle_error_nonverbose1(duk_hthread *thr, duk_errcode_t code, const char *fmt, ...) { |
|
|
|
duk_err_create_and_throw(thr, code); |
|
|
|
} |
|
|
|
|
|
|
|
void duk_err_handle_error_nonverbose2(const char *filename, int line, duk_hthread *thr, int code, const char *fmt, ...) { |
|
|
|
void duk_err_handle_error_nonverbose2(const char *filename, duk_int_t line, duk_hthread *thr, duk_errcode_t code, const char *fmt, ...) { |
|
|
|
duk_err_create_and_throw(thr, code); |
|
|
|
} |
|
|
|
#endif /* DUK_USE_VARIADIC_MACROS */ |
|
|
@ -69,15 +69,15 @@ void duk_err_handle_error_nonverbose2(const char *filename, int line, duk_hthrea |
|
|
|
* Default fatal error handler |
|
|
|
*/ |
|
|
|
|
|
|
|
void duk_default_fatal_handler(duk_context *ctx, int code, const char *msg) { |
|
|
|
void duk_default_fatal_handler(duk_context *ctx, duk_errcode_t code, const char *msg) { |
|
|
|
DUK_UNREF(ctx); |
|
|
|
#ifdef DUK_USE_FILE_IO |
|
|
|
DUK_FPRINTF(DUK_STDERR, "FATAL %d: %s\n", code, msg ? msg : "null"); |
|
|
|
DUK_FPRINTF(DUK_STDERR, "FATAL %d: %s\n", (int) code, msg ? msg : "null"); /* FIXME: format */ |
|
|
|
DUK_FFLUSH(DUK_STDERR); |
|
|
|
#else |
|
|
|
/* omit print */ |
|
|
|
#endif |
|
|
|
DUK_D(DUK_DPRINT("default fatal handler called, code %d -> calling DUK_PANIC()", code)); |
|
|
|
DUK_D(DUK_DPRINT("default fatal handler called, code %d -> calling DUK_PANIC()", (int) code)); |
|
|
|
DUK_PANIC(code, msg); |
|
|
|
DUK_UNREACHABLE(); |
|
|
|
} |
|
|
@ -87,7 +87,7 @@ void duk_default_fatal_handler(duk_context *ctx, int code, const char *msg) { |
|
|
|
*/ |
|
|
|
|
|
|
|
#if !defined(DUK_USE_PANIC_HANDLER) |
|
|
|
void duk_default_panic_handler(int code, const char *msg) { |
|
|
|
void duk_default_panic_handler(duk_errcode_t code, const char *msg) { |
|
|
|
#ifdef DUK_USE_FILE_IO |
|
|
|
DUK_FPRINTF(DUK_STDERR, "PANIC %d: %s (" |
|
|
|
#if defined(DUK_USE_PANIC_ABORT) |
|
|
@ -99,7 +99,7 @@ void duk_default_panic_handler(int code, const char *msg) { |
|
|
|
#else |
|
|
|
#error no DUK_USE_PANIC_xxx macro defined |
|
|
|
#endif |
|
|
|
")\n", code, msg ? msg : "null"); |
|
|
|
")\n", (int) code, msg ? msg : "null"); /* FIXME: format */ |
|
|
|
DUK_FFLUSH(DUK_STDERR); |
|
|
|
#else |
|
|
|
/* omit print */ |
|
|
|