]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | /* |
2 | * Do a longjmp call, calling the fatal error handler if no | |
3 | * catchpoint exists. | |
4 | */ | |
5 | ||
6 | #include "duk_internal.h" | |
7 | ||
8 | DUK_INTERNAL void duk_err_longjmp(duk_hthread *thr) { | |
9 | DUK_ASSERT(thr != NULL); | |
10 | ||
11 | DUK_DD(DUK_DDPRINT("longjmp error: type=%d iserror=%d value1=%!T value2=%!T", | |
12 | (int) thr->heap->lj.type, (int) thr->heap->lj.iserror, | |
13 | &thr->heap->lj.value1, &thr->heap->lj.value2)); | |
14 | ||
15 | #if !defined(DUK_USE_CPP_EXCEPTIONS) | |
16 | /* If we don't have a jmpbuf_ptr, there is little we can do | |
17 | * except panic. The caller's expectation is that we never | |
18 | * return. | |
19 | * | |
20 | * With C++ exceptions we now just propagate an uncaught error | |
21 | * instead of invoking the fatal error handler. Because there's | |
22 | * a dummy jmpbuf for C++ exceptions now, this could be changed. | |
23 | */ | |
24 | if (!thr->heap->lj.jmpbuf_ptr) { | |
25 | ||
26 | DUK_D(DUK_DPRINT("uncaught error: type=%d iserror=%d value1=%!T value2=%!T", | |
27 | (int) thr->heap->lj.type, (int) thr->heap->lj.iserror, | |
28 | &thr->heap->lj.value1, &thr->heap->lj.value2)); | |
29 | ||
30 | duk_fatal((duk_context *) thr, DUK_ERR_UNCAUGHT_ERROR, "uncaught error"); | |
31 | DUK_UNREACHABLE(); | |
32 | } | |
33 | #endif /* DUK_USE_CPP_EXCEPTIONS */ | |
34 | ||
35 | #if defined(DUK_USE_CPP_EXCEPTIONS) | |
36 | { | |
37 | duk_internal_exception exc; /* dummy */ | |
38 | throw exc; | |
39 | } | |
40 | #else /* DUK_USE_CPP_EXCEPTIONS */ | |
41 | DUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb); | |
42 | #endif /* DUK_USE_CPP_EXCEPTIONS */ | |
43 | ||
44 | DUK_UNREACHABLE(); | |
45 | } |