Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_error_macros.c File Reference
#include "duk_internal.h"

Go to the source code of this file.

Macros

#define DUK__ERRFMT_BUFSIZE   256 /* size for formatting buffers */
 

Functions

DUK_INTERNAL void duk_err_handle_error_fmt (duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *fmt,...)
 
DUK_INTERNAL void duk_err_handle_error (duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *msg)
 
DUK_INTERNAL void duk_err_require_type_index (duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index, const char *expect_name)
 
DUK_INTERNAL void duk_err_range (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_err_api_index (duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t index)
 
DUK_INTERNAL void duk_err_api (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_err_unimplemented_defmsg (duk_hthread *thr, const char *filename, duk_int_t linenumber)
 
DUK_INTERNAL void duk_err_internal_defmsg (duk_hthread *thr, const char *filename, duk_int_t linenumber)
 
DUK_INTERNAL void duk_err_internal (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_err_alloc (duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)
 
DUK_INTERNAL void duk_default_fatal_handler (duk_context *ctx, duk_errcode_t code, const char *msg)
 
DUK_INTERNAL void duk_default_panic_handler (duk_errcode_t code, const char *msg)
 

Macro Definition Documentation

◆ DUK__ERRFMT_BUFSIZE

#define DUK__ERRFMT_BUFSIZE   256 /* size for formatting buffers */

Function Documentation

◆ duk_default_fatal_handler()

DUK_INTERNAL void duk_default_fatal_handler ( duk_context * ctx,
duk_errcode_t code,
const char * msg )

Definition at line 109 of file duktape-1.8.0/src-separate/duk_error_macros.c.

109 {
110 DUK_UNREF(ctx);
111#if defined(DUK_USE_FILE_IO)
112 DUK_FPRINTF(DUK_STDERR, "FATAL %ld: %s\n", (long) code, (const char *) (msg ? msg : "null"));
114#else
115 /* omit print */
116#endif
117 DUK_D(DUK_DPRINT("default fatal handler called, code %ld -> calling DUK_PANIC()", (long) code));
118 DUK_PANIC(code, msg);
120}
#define DUK_PANIC(code, msg)

References DUK_D, DUK_DPRINT, DUK_FFLUSH, DUK_FPRINTF, DUK_PANIC, DUK_STDERR, DUK_UNREACHABLE, and DUK_UNREF.

◆ duk_default_panic_handler()

DUK_INTERNAL void duk_default_panic_handler ( duk_errcode_t code,
const char * msg )

Definition at line 127 of file duktape-1.8.0/src-separate/duk_error_macros.c.

127 {
128#if defined(DUK_USE_FILE_IO)
129 DUK_FPRINTF(DUK_STDERR, "PANIC %ld: %s ("
130#if defined(DUK_USE_PANIC_ABORT)
131 "calling abort"
132#elif defined(DUK_USE_PANIC_EXIT)
133 "calling exit"
134#elif defined(DUK_USE_PANIC_SEGFAULT)
135 "segfaulting on purpose"
136#else
137#error no DUK_USE_PANIC_xxx macro defined
138#endif
139 ")\n", (long) code, (const char *) (msg ? msg : "null"));
141#else
142 /* omit print */
143 DUK_UNREF(code);
144 DUK_UNREF(msg);
145#endif
146
147#if defined(DUK_USE_PANIC_ABORT)
148 DUK_ABORT();
149#elif defined(DUK_USE_PANIC_EXIT)
150 DUK_EXIT(-1);
151#elif defined(DUK_USE_PANIC_SEGFAULT)
152 /* exit() afterwards to satisfy "noreturn" */
153 DUK_CAUSE_SEGFAULT(); /* SCANBUILD: "Dereference of null pointer", normal */
154 DUK_EXIT(-1);
155#else
156#error no DUK_USE_PANIC_xxx macro defined
157#endif
158
160}
static void error(LoadState *S, const char *why)

References DUK_ABORT, DUK_CAUSE_SEGFAULT, DUK_EXIT, DUK_FFLUSH, DUK_FPRINTF, DUK_STDERR, DUK_UNREACHABLE, DUK_UNREF, DUK_USE_PANIC_ABORT, and error().

◆ duk_err_alloc()

DUK_INTERNAL void duk_err_alloc ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 72 of file duktape-1.8.0/src-separate/duk_error_macros.c.

72 {
73 DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_ALLOC_ERROR, message);
74}
#define DUK_ERROR_RAW(thr, file, line, err, msg)
#define DUK_ERR_ALLOC_ERROR

References DUK_ERR_ALLOC_ERROR, and DUK_ERROR_RAW.

◆ duk_err_api()

DUK_INTERNAL void duk_err_api ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 55 of file duktape-1.8.0/src-separate/duk_error_macros.c.

55 {
56 DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_API_ERROR, message);
57}

References DUK_ERR_API_ERROR, and DUK_ERROR_RAW.

◆ duk_err_api_index()

DUK_INTERNAL void duk_err_api_index ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
duk_idx_t index )

Definition at line 52 of file duktape-1.8.0/src-separate/duk_error_macros.c.

52 {
53 DUK_ERROR_RAW_FMT1(thr, filename, linenumber, DUK_ERR_API_ERROR, "invalid stack index %ld", (long) (index));
54}
guint index
#define DUK_ERROR_RAW_FMT1(thr, file, line, err, fmt, arg1)

References DUK_ERR_API_ERROR, DUK_ERROR_RAW_FMT1, and index.

◆ duk_err_handle_error()

DUK_INTERNAL void duk_err_handle_error ( duk_hthread * thr,
const char * filename,
duk_uint_t line_and_code,
const char * msg )

Definition at line 21 of file duktape-1.8.0/src-separate/duk_error_macros.c.

21 {
22 duk_err_create_and_throw(thr, (duk_errcode_t) (line_and_code >> 24), msg, filename, (duk_int_t) (line_and_code & 0x00ffffffL));
23}
duk_int_fast32_t duk_int_t
DUK_INTERNAL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line)

References duk_err_create_and_throw().

◆ duk_err_handle_error_fmt()

DUK_INTERNAL void duk_err_handle_error_fmt ( duk_hthread * thr,
const char * filename,
duk_uint_t line_and_code,
const char * fmt,
... )

Definition at line 11 of file duktape-1.8.0/src-separate/duk_error_macros.c.

11 {
12 va_list ap;
13 char msg[DUK__ERRFMT_BUFSIZE];
14 va_start(ap, fmt);
15 (void) DUK_VSNPRINTF(msg, sizeof(msg), fmt, ap);
16 msg[sizeof(msg) - 1] = (char) 0;
17 duk_err_create_and_throw(thr, (duk_errcode_t) (line_and_code >> 24), msg, filename, (duk_int_t) (line_and_code & 0x00ffffffL));
18 va_end(ap); /* dead code, but ensures portability (see Linux man page notes) */
19}

References DUK__ERRFMT_BUFSIZE, duk_err_create_and_throw(), and DUK_VSNPRINTF.

◆ duk_err_internal()

DUK_INTERNAL void duk_err_internal ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 69 of file duktape-1.8.0/src-separate/duk_error_macros.c.

69 {
70 DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_INTERNAL_ERROR, message);
71}
#define DUK_ERR_INTERNAL_ERROR

References DUK_ERR_INTERNAL_ERROR, and DUK_ERROR_RAW.

◆ duk_err_internal_defmsg()

DUK_INTERNAL void duk_err_internal_defmsg ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber )

◆ duk_err_range()

DUK_INTERNAL void duk_err_range ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
const char * message )

Definition at line 49 of file duktape-1.8.0/src-separate/duk_error_macros.c.

49 {
50 DUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_RANGE_ERROR, message);
51}
#define DUK_ERR_RANGE_ERROR

References DUK_ERR_RANGE_ERROR, and DUK_ERROR_RAW.

◆ duk_err_require_type_index()

DUK_INTERNAL void duk_err_require_type_index ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber,
duk_idx_t index,
const char * expect_name )

Definition at line 44 of file duktape-1.8.0/src-separate/duk_error_macros.c.

44 {
45 DUK_ERROR_RAW_FMT3(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, "%s required, found %s (stack index %ld)",
46 expect_name, duk_push_string_readable((duk_context *) thr, index), (long) index);
47}
DUK_INTERNAL_DECL const char * duk_push_string_readable(duk_context *ctx, duk_idx_t index)
#define DUK_ERROR_RAW_FMT3(thr, file, line, err, fmt, arg1, arg2, arg3)

References DUK_ERR_TYPE_ERROR, DUK_ERROR_RAW_FMT3, duk_push_string_readable(), and index.

◆ duk_err_unimplemented_defmsg()

DUK_INTERNAL void duk_err_unimplemented_defmsg ( duk_hthread * thr,
const char * filename,
duk_int_t linenumber )