root/WizardsToolkit/trunk/wizard/exception-private.h

Revision 1, 2.1 KB (checked in by cristy, 3 months ago)


Line 
1/*
2  Copyright 1999-2009 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    http://www.wizards-toolkit.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#if defined(__cplusplus) || defined(c_plusplus)
22extern "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
Note: See TracBrowser for help on using the browser.