MagickCore 7.0.10
exception-private.h
Go to the documentation of this file.
1/*
2 Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
4
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
7
8 https://imagemagick.org/script/license.php
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 Wizard's Toolkit private exception methods.
17*/
18#ifndef _WIZARDSTOOLKIT_EXCEPTION_PRIVATE_H
19#define _WIZARDSTOOLKIT_EXCEPTION_PRIVATE_H
20
21#include "wizard/log.h"
22#include "wizard/string_.h"
23#include "wizard/wizard.h"
24
25#if defined(__cplusplus) || defined(c_plusplus)
26extern "C" {
27#endif
28
29#define CatchWizardException(severity,tag,context) \
30{ \
31 ExceptionInfo \
32 *exception; \
33 \
34 exception=AcquireExceptionInfo(); \
35 (void) ThrowWizardException(exception,GetWizardModule(),severity,tag,context); \
36 CatchException(exception); \
37 exception=DestroyExceptionInfo(exception); \
38}
39
40#if defined(WIZARDSTOOLKIT_Debug)
41#define WizardAssert(domain,predicate) \
42{ \
43 assert(predicate); \
44}
45#else
46#define WizardAssert(domain,predicate) \
47{ \
48 if ((WizardBooleanType) (predicate) == WizardFalse) \
49 ThrowWizardFatalError(domain,AssertError); \
50}
51#endif
52
53#define ThrowFileException(exception,severity,context) \
54{ \
55 char \
56 *message; \
57 \
58 message=GetExceptionMessage(errno); \
59 (void) ThrowWizardException(exception,GetWizardModule(),severity, \
60 "file exception `%s': %s",context,message); \
61 message=DestroyString(message); \
62}
63
64#define ThrowWizardFatalError(domain,error) \
65{ \
66 char \
67 context[WizardPathExtent], \
68 tag[WizardPathExtent]; \
69 \
70 (void) FormatLocaleString(tag,WizardPathExtent,"%ld\n",(long) domain); \
71 (void) FormatLocaleString(context,WizardPathExtent,"%ld\n",(long) error); \
72 CatchWizardException(UndefinedException,tag,context); \
73 WizardsToolkitTerminus(); \
74 _exit((domain << 3) | error); \
75}
76
77#define ThrowFatalException(severity,tag) \
78{ \
79 char \
80 *message; \
81 \
82 message=GetExceptionMessage(errno); \
83 CatchWizardException(severity,tag,message); \
84 message=DestroyString(message); \
85 WizardsToolkitTerminus(); \
86 _exit(127); \
87}
88
89#if defined(__cplusplus) || defined(c_plusplus)
90}
91#endif
92
93#endif