Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_error.h File Reference

Go to the source code of this file.

Macros

#define DUK_ERROR(thr, err, msg)   duk_err_handle_error((thr), (err))
 
#define DUK_ERROR_RAW(thr, file, line, err, msg)   duk_err_handle_error((thr), (err))
 
#define DUK_ERROR_FMT1(thr, err, fmt, arg1)   DUK_ERROR((thr),(err),(fmt))
 
#define DUK_ERROR_RAW_FMT1(thr, file, line, err, fmt, arg1)   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))
 
#define DUK_ERROR_FMT2(thr, err, fmt, arg1, arg2)   DUK_ERROR((thr),(err),(fmt))
 
#define DUK_ERROR_RAW_FMT2(thr, file, line, err, fmt, arg1, arg2)   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))
 
#define DUK_ERROR_FMT3(thr, err, fmt, arg1, arg2, arg3)   DUK_ERROR((thr),(err),(fmt))
 
#define DUK_ERROR_RAW_FMT3(thr, file, line, err, fmt, arg1, arg2, arg3)   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))
 
#define DUK_ERROR_FMT4(thr, err, fmt, arg1, arg2, arg3, arg4)   DUK_ERROR((thr),(err),(fmt))
 
#define DUK_ERROR_RAW_FMT4(thr, file, line, err, fmt, arg1, arg2, arg3, arg4)   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))
 
#define DUK_PANIC(code, msg)   duk_default_panic_handler((code),(msg))
 
#define DUK_ASSERT(x)   do { /* assertion omitted */ } while (0)
 
#define DUK_ASSERT_EXPR(x)   ((void) 0)
 
#define DUK_ASSERT_DISABLE(x)   do { /* assertion disabled */ } while (0)
 
#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(h)   /* no refcount check */
 
#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL(tv)   /* no refcount check */
 
#define DUK_ASSERT_TOP(ctx, n)   DUK_ASSERT((duk_idx_t) duk_get_top((ctx)) == (duk_idx_t) (n))
 
#define DUK_ASSERT_DOUBLE_IS_NORMALIZED(dval)   /* nop */
 
#define DUK_VALSTACK_ASSERT_EXTRA
 
#define DUK_ASSERT_VALSTACK_SPACE(thr, n)   /* no valstack space check */
 
#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr, index, expectname, lowmemstr)
 
#define DUK_ERROR_UNIMPLEMENTED(thr, msg)
 
#define DUK_ERROR_UNIMPLEMENTED_DEFMSG(thr)
 
#define DUK_ERROR_UNSUPPORTED(thr, msg)
 
#define DUK_ERROR_UNSUPPORTED_DEFMSG(thr)
 
#define DUK_ERROR_INTERNAL(thr, msg)
 
#define DUK_ERROR_INTERNAL_DEFMSG(thr)
 
#define DUK_ERROR_ALLOC(thr, msg)
 
#define DUK_ERROR_ALLOC_DEFMSG(thr)
 
#define DUK_ERROR_API_INDEX(thr, index)
 
#define DUK_ERROR_API(thr, msg)
 
#define DUK_ERROR_RANGE(thr, msg)
 
#define DUK_ERROR_SYNTAX(thr, msg)
 
#define DUK_ERROR_TYPE(thr, msg)
 

Functions

 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_handle_error(duk_hthread *thr, duk_errcode_t code))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_error_throw_from_negative_rc(duk_hthread *thr, duk_ret_t rc))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_err_range(duk_hthread *thr))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_default_fatal_handler(duk_context *ctx, duk_errcode_t code, const char *msg))
 
 DUK_NORETURN (DUK_INTERNAL_DECL void duk_default_panic_handler(duk_errcode_t code, const char *msg))
 
DUK_INTERNAL_DECL void duk_err_setup_heap_ljstate (duk_hthread *thr, duk_small_int_t lj_type)
 
DUK_INTERNAL_DECL duk_hobjectduk_error_prototype_from_code (duk_hthread *thr, duk_errcode_t err_code)
 

Macro Definition Documentation

◆ DUK_ASSERT

#define DUK_ASSERT ( x)    do { /* assertion omitted */ } while (0)

Definition at line 193 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_DISABLE

#define DUK_ASSERT_DISABLE ( x)    do { /* assertion disabled */ } while (0)

Definition at line 202 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_DOUBLE_IS_NORMALIZED

#define DUK_ASSERT_DOUBLE_IS_NORMALIZED ( dval)    /* nop */

Definition at line 231 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_EXPR

#define DUK_ASSERT_EXPR ( x)    ((void) 0)

Definition at line 195 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR

#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR ( h)    /* no refcount check */

Definition at line 218 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_REFCOUNT_NONZERO_TVAL

#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL ( tv)    /* no refcount check */

Definition at line 219 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_TOP

#define DUK_ASSERT_TOP ( ctx,
n )   DUK_ASSERT((duk_idx_t) duk_get_top((ctx)) == (duk_idx_t) (n))

Definition at line 222 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ASSERT_VALSTACK_SPACE

#define DUK_ASSERT_VALSTACK_SPACE ( thr,
n )   /* no valstack space check */

Definition at line 249 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR

#define DUK_ERROR ( thr,
err,
msg )   duk_err_handle_error((thr), (err))

Definition at line 112 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_ALLOC

#define DUK_ERROR_ALLOC ( thr,
msg )
Value:
do { \
duk_err_alloc((thr)); \
} while (0)

Definition at line 349 of file duktape-1.5.2/src-separate/duk_error.h.

349 duk_err_internal((thr)); \
350 } while (0)
351#define DUK_ERROR_ALLOC(thr,msg) do { \
DUK_INTERNAL void duk_err_internal(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)

◆ DUK_ERROR_ALLOC_DEFMSG

#define DUK_ERROR_ALLOC_DEFMSG ( thr)
Value:
do { \
duk_err_alloc((thr)); \
} while (0)

Definition at line 352 of file duktape-1.5.2/src-separate/duk_error.h.

352 duk_err_alloc((thr)); \
353 } while (0)
354#define DUK_ERROR_ALLOC_DEFMSG(thr) do { \
DUK_INTERNAL void duk_err_alloc(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)

◆ DUK_ERROR_API

#define DUK_ERROR_API ( thr,
msg )
Value:
do { \
duk_err_api((thr)); \
} while (0)

Definition at line 358 of file duktape-1.5.2/src-separate/duk_error.h.

358 duk_err_api((thr)); \
359 } while (0)
360#define DUK_ERROR_API(thr,msg) do { \
DUK_INTERNAL void duk_err_api(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)

◆ DUK_ERROR_API_INDEX

#define DUK_ERROR_API_INDEX ( thr,
index )
Value:
do { \
duk_err_api((thr)); \
} while (0)

Definition at line 355 of file duktape-1.5.2/src-separate/duk_error.h.

355 duk_err_alloc((thr)); \
356 } while (0)
357#define DUK_ERROR_API_INDEX(thr,index) do { \

◆ DUK_ERROR_FMT1

#define DUK_ERROR_FMT1 ( thr,
err,
fmt,
arg1 )   DUK_ERROR((thr),(err),(fmt))

Definition at line 115 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_FMT2

#define DUK_ERROR_FMT2 ( thr,
err,
fmt,
arg1,
arg2 )   DUK_ERROR((thr),(err),(fmt))

Definition at line 118 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_FMT3

#define DUK_ERROR_FMT3 ( thr,
err,
fmt,
arg1,
arg2,
arg3 )   DUK_ERROR((thr),(err),(fmt))

Definition at line 121 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_FMT4

#define DUK_ERROR_FMT4 ( thr,
err,
fmt,
arg1,
arg2,
arg3,
arg4 )   DUK_ERROR((thr),(err),(fmt))

Definition at line 124 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_INTERNAL

#define DUK_ERROR_INTERNAL ( thr,
msg )
Value:
do { \
duk_err_internal((thr)); \
} while (0)

Definition at line 343 of file duktape-1.5.2/src-separate/duk_error.h.

343 duk_err_unsupported((thr)); \
344 } while (0)
345#define DUK_ERROR_INTERNAL(thr,msg) do { \

◆ DUK_ERROR_INTERNAL_DEFMSG

#define DUK_ERROR_INTERNAL_DEFMSG ( thr)
Value:
do { \
duk_err_internal((thr)); \
} while (0)

Definition at line 346 of file duktape-1.5.2/src-separate/duk_error.h.

346 duk_err_internal((thr)); \
347 } while (0)
348#define DUK_ERROR_INTERNAL_DEFMSG(thr) do { \

◆ DUK_ERROR_RANGE

#define DUK_ERROR_RANGE ( thr,
msg )
Value:
do { \
duk_err_range((thr)); \
} while (0)

Definition at line 361 of file duktape-1.5.2/src-separate/duk_error.h.

361 duk_err_api((thr)); \
362 } while (0)
363#define DUK_ERROR_RANGE(thr,msg) do { \

◆ DUK_ERROR_RAW

#define DUK_ERROR_RAW ( thr,
file,
line,
err,
msg )   duk_err_handle_error((thr), (err))

Definition at line 113 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_RAW_FMT1

#define DUK_ERROR_RAW_FMT1 ( thr,
file,
line,
err,
fmt,
arg1 )   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))

Definition at line 116 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_RAW_FMT2

#define DUK_ERROR_RAW_FMT2 ( thr,
file,
line,
err,
fmt,
arg1,
arg2 )   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))

Definition at line 119 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_RAW_FMT3

#define DUK_ERROR_RAW_FMT3 ( thr,
file,
line,
err,
fmt,
arg1,
arg2,
arg3 )   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))

Definition at line 122 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_RAW_FMT4

#define DUK_ERROR_RAW_FMT4 ( thr,
file,
line,
err,
fmt,
arg1,
arg2,
arg3,
arg4 )   DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))

Definition at line 125 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_ERROR_REQUIRE_TYPE_INDEX

#define DUK_ERROR_REQUIRE_TYPE_INDEX ( thr,
index,
expectname,
lowmemstr )
Value:
do { \
duk_err_type((thr)); \
} while (0)

Definition at line 327 of file duktape-1.5.2/src-separate/duk_error.h.

327/* Non-verbose errors for low memory targets: no file, line, or message. */
328
329#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,index,expectname,lowmemstr) do { \

◆ DUK_ERROR_SYNTAX

#define DUK_ERROR_SYNTAX ( thr,
msg )
Value:
do { \
duk_err_syntax((thr)); \
} while (0)

Definition at line 364 of file duktape-1.5.2/src-separate/duk_error.h.

364 duk_err_range((thr)); \
365 } while (0)
366#define DUK_ERROR_SYNTAX(thr,msg) do { \
DUK_INTERNAL void duk_err_range(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message)

◆ DUK_ERROR_TYPE

#define DUK_ERROR_TYPE ( thr,
msg )
Value:
do { \
duk_err_type((thr)); \
} while (0)

Definition at line 367 of file duktape-1.5.2/src-separate/duk_error.h.

367 duk_err_syntax((thr)); \
368 } while (0)
369#define DUK_ERROR_TYPE(thr,msg) do { \

◆ DUK_ERROR_UNIMPLEMENTED

#define DUK_ERROR_UNIMPLEMENTED ( thr,
msg )
Value:
do { \
duk_err_unimplemented((thr)); \
} while (0)

Definition at line 331 of file duktape-1.5.2/src-separate/duk_error.h.

331 } while (0)
332
333#define DUK_ERROR_UNIMPLEMENTED(thr,msg) do { \

◆ DUK_ERROR_UNIMPLEMENTED_DEFMSG

#define DUK_ERROR_UNIMPLEMENTED_DEFMSG ( thr)
Value:
do { \
duk_err_unimplemented((thr)); \
} while (0)

Definition at line 334 of file duktape-1.5.2/src-separate/duk_error.h.

334 duk_err_unimplemented((thr)); \
335 } while (0)
336#define DUK_ERROR_UNIMPLEMENTED_DEFMSG(thr) do { \

◆ DUK_ERROR_UNSUPPORTED

#define DUK_ERROR_UNSUPPORTED ( thr,
msg )
Value:
do { \
duk_err_unsupported((thr)); \
} while (0)

Definition at line 337 of file duktape-1.5.2/src-separate/duk_error.h.

337 duk_err_unimplemented((thr)); \
338 } while (0)
339#define DUK_ERROR_UNSUPPORTED(thr,msg) do { \

◆ DUK_ERROR_UNSUPPORTED_DEFMSG

#define DUK_ERROR_UNSUPPORTED_DEFMSG ( thr)
Value:
do { \
duk_err_unsupported((thr)); \
} while (0)

Definition at line 340 of file duktape-1.5.2/src-separate/duk_error.h.

340 duk_err_unsupported((thr)); \
341 } while (0)
342#define DUK_ERROR_UNSUPPORTED_DEFMSG(thr) do { \

Referenced by duk__call_prop_prep_stack().

◆ DUK_PANIC

#define DUK_PANIC ( code,
msg )   duk_default_panic_handler((code),(msg))

Definition at line 156 of file duktape-1.5.2/src-separate/duk_error.h.

◆ DUK_VALSTACK_ASSERT_EXTRA

#define DUK_VALSTACK_ASSERT_EXTRA
Value:
5 /* this is added to checks to allow for Duktape
* API calls in addition to function's own use
*/

Definition at line 242 of file duktape-1.5.2/src-separate/duk_error.h.

Function Documentation

◆ duk_err_setup_heap_ljstate()

DUK_INTERNAL_DECL void duk_err_setup_heap_ljstate ( duk_hthread * thr,
duk_small_int_t lj_type )

Definition at line 40226 of file duktape-1.5.2/src-noline/duktape.c.

40228 :
40232 case DUK_ERR_API_ERROR:
40233 case DUK_ERR_ERROR:
40234 default:
40236 }
40237}
40238
40239/*
40240 * Exposed helper for setting up heap longjmp state.
40241 */
40242
40244#if defined(DUK_USE_DEBUGGER_SUPPORT)
40245 /* If something is thrown with the debugger attached and nobody will
40246 * catch it, execution is paused before the longjmp, turning over
40247 * control to the debug client. This allows local state to be examined
40248 * before the stack is unwound. Errors are not intercepted when debug
40249 * message loop is active (e.g. for Eval).
40250 */
40251
40252 /* XXX: Allow customizing the pause and notify behavior at runtime
40253 * using debugger runtime flags. For now the behavior is fixed using
40254 * config options.
40255 */
40256#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY) || defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)
40257 if (DUK_HEAP_IS_DEBUGGER_ATTACHED(thr->heap) &&
40258 !thr->heap->dbg_processing &&
40259 lj_type == DUK_LJ_TYPE_THROW) {
40260 duk_context *ctx = (duk_context *) thr;
40262 duk_hobject *h_obj;
40263
40264 /* Don't intercept a DoubleError, we may have caused the initial double
40265 * fault and attempting to intercept it will cause us to be called
40266 * recursively and exhaust the C stack.
40267 */
40268 h_obj = duk_get_hobject(ctx, -1);
40269 if (h_obj == thr->builtins[DUK_BIDX_DOUBLE_ERROR]) {
40270 DUK_D(DUK_DPRINT("built-in DoubleError instance thrown, not intercepting"));
40271 goto skip_throw_intercept;
40272 }
40273
40274 DUK_D(DUK_DPRINT("throw with debugger attached, report to client"));
40275
40276 fatal = !duk__have_active_catcher(thr);
40277
40278#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY)
40279 /* Report it to the debug client */
40280 duk_debug_send_throw(thr, fatal);
40281#endif
40282
40283#if defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)
40284 if (fatal) {
duk_small_int_t duk_bool_t
DUK_INTERNAL_DECL void duk_err_setup_heap_ljstate(duk_hthread *thr, duk_small_int_t lj_type)
#define DUK_BIDX_DOUBLE_ERROR
#define DUK_BIDX_ERROR_PROTOTYPE
DUK_INTERNAL_DECL duk_hobject * duk_get_hobject(duk_context *ctx, duk_idx_t index)
#define DUK_ERR_ALLOC_ERROR
#define DUK_ERR_INTERNAL_ERROR
#define DUK_ERR_ASSERTION_ERROR
static void fatal(const char *message)
duk_hobject * builtins[DUK_NUM_BUILTINS]

◆ duk_error_prototype_from_code()

DUK_INTERNAL_DECL duk_hobject * duk_error_prototype_from_code ( duk_hthread * thr,
duk_errcode_t err_code )

Definition at line 40195 of file duktape-1.5.2/src-noline/duktape.c.

40195 {
40196 for (i = 0; i < thr->catchstack_top; i++) {
40197 duk_catcher *cat = thr->catchstack + i;
40198 if (DUK_CAT_HAS_CATCH_ENABLED(cat)) {
40199 return 1; /* all we need to know */
40200 }
40201 }
40202 thr = thr->resumer;
40203 }
40204 return 0;
40205}
40206#endif /* DUK_USE_DEBUGGER_SUPPORT && (DUK_USE_DEBUGGER_THROW_NOTIFY || DUK_USE_DEBUGGER_PAUSE_UNCAUGHT) */
40207
40208/*
40209 * Get prototype object for an integer error code.
40210 */
40211
40213 switch (code) {
40214 case DUK_ERR_EVAL_ERROR:
#define DUK_BIDX_EVAL_ERROR_PROTOTYPE
DUK_INTERNAL_DECL duk_hobject * duk_error_prototype_from_code(duk_hthread *thr, duk_errcode_t err_code)
#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE
#define DUK_CAT_HAS_CATCH_ENABLED(c)
#define DUK_BIDX_RANGE_ERROR_PROTOTYPE
#define DUK_ERR_SYNTAX_ERROR
#define DUK_ERR_RANGE_ERROR
#define DUK_ERR_REFERENCE_ERROR

◆ DUK_NORETURN() [1/5]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_default_fatal_handlerduk_context *ctx, duk_errcode_t code, const char *msg)

◆ DUK_NORETURN() [2/5]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_default_panic_handlerduk_errcode_t code, const char *msg)

◆ DUK_NORETURN() [3/5]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_handle_errorduk_hthread *thr, duk_errcode_t code)

◆ DUK_NORETURN() [4/5]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_err_rangeduk_hthread *thr)

◆ DUK_NORETURN() [5/5]

DUK_NORETURN ( DUK_INTERNAL_DECL void duk_error_throw_from_negative_rcduk_hthread *thr, duk_ret_t rc)