| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #ifndef _WIZARDSTOOLKIT_EXCEPTION_PRIVATE_H |
|---|
| 19 | #define _WIZARDSTOOLKIT_EXCEPTION_PRIVATE_H |
|---|
| 20 | |
|---|
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 22 | extern "C" { |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | #include "wizard/log.h" |
|---|
| 26 | |
|---|
| 27 | #define CatchWizardException(severity,tag,context) \ |
|---|
| 28 | { \ |
|---|
| 29 | ExceptionInfo \ |
|---|
| 30 | *exception; \ |
|---|
| 31 | \ |
|---|
| 32 | exception=AcquireExceptionInfo(); \ |
|---|
| 33 | (void) ThrowWizardException(exception,GetWizardModule(),severity,tag,context); \ |
|---|
| 34 | CatchException(exception); \ |
|---|
| 35 | exception=DestroyExceptionInfo(exception); \ |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | #if defined(WIZARDSTOOLKIT_Debug) |
|---|
| 39 | #define WizardAssert(domain,predicate) \ |
|---|
| 40 | { \ |
|---|
| 41 | assert(predicate); \ |
|---|
| 42 | } |
|---|
| 43 | #else |
|---|
| 44 | #define WizardAssert(domain,predicate) \ |
|---|
| 45 | { \ |
|---|
| 46 | if ((WizardBooleanType) (predicate) == WizardFalse) \ |
|---|
| 47 | ThrowWizardFatalError(domain,AssertError); \ |
|---|
| 48 | } |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | #define ThrowFileException(exception,severity,context) \ |
|---|
| 52 | { \ |
|---|
| 53 | (void) ThrowWizardException(exception,GetWizardModule(),severity, \ |
|---|
| 54 | "file exception `%s': %s",context,strerror(errno)); \ |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | #define ThrowWizardFatalError(domain,error) \ |
|---|
| 58 | { \ |
|---|
| 59 | char \ |
|---|
| 60 | context[MaxTextExtent], \ |
|---|
| 61 | tag[MaxTextExtent]; \ |
|---|
| 62 | \ |
|---|
| 63 | (void) FormatWizardString(tag,MaxTextExtent,"%ld\n",(long) domain); \ |
|---|
| 64 | (void) FormatWizardString(context,MaxTextExtent,"%ld\n",(long) error); \ |
|---|
| 65 | CatchWizardException(UndefinedException,tag,context); \ |
|---|
| 66 | _exit((domain << 3) | error); \ |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | #define ThrowFatalException(severity,tag) \ |
|---|
| 70 | { \ |
|---|
| 71 | CatchWizardException(severity,tag,strerror(errno)); \ |
|---|
| 72 | _exit(127); \ |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | #if defined(__cplusplus) || defined(c_plusplus) |
|---|
| 76 | } |
|---|
| 77 | #endif |
|---|
| 78 | |
|---|
| 79 | #endif |
|---|