]> granicus.if.org Git - imagemagick/blob - MagickCore/exception-private.h
6376a2b619873dd54d3a26bb580d14b5dd53b23e
[imagemagick] / MagickCore / exception-private.h
1 /*
2   Copyright 1999-2012 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.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)
22 extern "C" {
23 #endif
24
25 #include "MagickCore/log.h"
26 #include "MagickCore/string_.h"
27
28 #define ThrowBinaryException(severity,tag,context) \
29 { \
30   if (image != (Image *) NULL) \
31     (void) ThrowMagickException(exception,GetMagickModule(),severity, \
32       tag == (const char *) NULL ? "unknown" : tag,"'%s'",context); \
33   return(MagickFalse); \
34 }
35 #define ThrowFatalException(severity,tag) \
36 { \
37   char \
38     *message; \
39  \
40   ExceptionInfo \
41     exception; \
42  \
43   GetExceptionInfo(&exception); \
44   message=GetExceptionMessage(errno); \
45   (void) ThrowMagickException(&exception,GetMagickModule(),severity, \
46     tag == (const char *) NULL ? "unknown" : tag,"'%s'",message); \
47   message=DestroyString(message); \
48   CatchException(&exception); \
49   (void) DestroyExceptionInfo(&exception); \
50   _exit(1); \
51 }
52 #define ThrowFileException(exception,severity,tag,context) \
53 { \
54   char \
55     *message; \
56  \
57   message=GetExceptionMessage(errno); \
58   (void) ThrowMagickException(exception,GetMagickModule(),severity, \
59     tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context,message); \
60   message=DestroyString(message); \
61 }
62 #define ThrowImageException(severity,tag) \
63 { \
64   (void) ThrowMagickException(exception,GetMagickModule(),severity, \
65     tag == (const char *) NULL ? "unknown" : tag,"'%s'",image->filename); \
66   return((Image *) NULL); \
67 }
68 #define ThrowReaderException(severity,tag) \
69 { \
70   (void) ThrowMagickException(exception,GetMagickModule(),severity, \
71     tag == (const char *) NULL ? "unknown" : tag,"'%s'",image_info->filename); \
72   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 { \
81   (void) ThrowMagickException(exception,GetMagickModule(),severity, \
82     tag == (const char *) NULL ? "unknown" : tag,"'%s'",image->filename); \
83   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