blob: 6376a2b619873dd54d3a26bb580d14b5dd53b23e [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy1454be72011-12-19 01:52:48 +00002 Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
cristy3ed852e2009-09-05 21:47:34 +00003 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.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 MagickCore exception private methods.
17*/
18#ifndef _MAGICKCORE_EXCEPTION_PRIVATE_H
19#define _MAGICKCORE_EXCEPTION_PRIVATE_H
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
cristy4c08aed2011-07-01 19:47:50 +000025#include "MagickCore/log.h"
26#include "MagickCore/string_.h"
cristy3ed852e2009-09-05 21:47:34 +000027
28#define ThrowBinaryException(severity,tag,context) \
29{ \
30 if (image != (Image *) NULL) \
cristy018f07f2011-09-04 21:15:19 +000031 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000032 tag == (const char *) NULL ? "unknown" : tag,"'%s'",context); \
cristy3ed852e2009-09-05 21:47:34 +000033 return(MagickFalse); \
34}
35#define ThrowFatalException(severity,tag) \
36{ \
cristy5bf97b52011-01-24 13:21:15 +000037 char \
38 *message; \
39 \
cristy3ed852e2009-09-05 21:47:34 +000040 ExceptionInfo \
41 exception; \
42 \
43 GetExceptionInfo(&exception); \
cristy5bf97b52011-01-24 13:21:15 +000044 message=GetExceptionMessage(errno); \
cristy3ed852e2009-09-05 21:47:34 +000045 (void) ThrowMagickException(&exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000046 tag == (const char *) NULL ? "unknown" : tag,"'%s'",message); \
cristy5bf97b52011-01-24 13:21:15 +000047 message=DestroyString(message); \
cristy3ed852e2009-09-05 21:47:34 +000048 CatchException(&exception); \
49 (void) DestroyExceptionInfo(&exception); \
50 _exit(1); \
51}
52#define ThrowFileException(exception,severity,tag,context) \
53{ \
cristy5bf97b52011-01-24 13:21:15 +000054 char \
55 *message; \
56 \
57 message=GetExceptionMessage(errno); \
cristy3ed852e2009-09-05 21:47:34 +000058 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000059 tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context,message); \
cristy5bf97b52011-01-24 13:21:15 +000060 message=DestroyString(message); \
cristy3ed852e2009-09-05 21:47:34 +000061}
62#define ThrowImageException(severity,tag) \
63{ \
64 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000065 tag == (const char *) NULL ? "unknown" : tag,"'%s'",image->filename); \
cristy3ed852e2009-09-05 21:47:34 +000066 return((Image *) NULL); \
67}
68#define ThrowReaderException(severity,tag) \
69{ \
70 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000071 tag == (const char *) NULL ? "unknown" : tag,"'%s'",image_info->filename); \
cristy3ed852e2009-09-05 21:47:34 +000072 if ((image) != (Image *) NULL) \
73 { \
74 (void) CloseBlob(image); \
75 image=DestroyImageList(image); \
76 } \
77 return((Image *) NULL); \
78}
79#define ThrowWriterException(severity,tag) \
80{ \
cristy018f07f2011-09-04 21:15:19 +000081 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000082 tag == (const char *) NULL ? "unknown" : tag,"'%s'",image->filename); \
cristy3ed852e2009-09-05 21:47:34 +000083 if (image_info->adjoin != MagickFalse) \
84 while (image->previous != (Image *) NULL) \
85 image=image->previous; \
86 (void) CloseBlob(image); \
87 return(MagickFalse); \
88}
89
90#if defined(__cplusplus) || defined(c_plusplus)
91}
92#endif
93
94#endif