blob: 558c60bbd4560df203a4a0ab0973c0dc6136d44a [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy7e41fe82010-12-04 23:12:08 +00002 Copyright 1999-2011 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
25#include "magick/log.h"
cristyd7ecaca2011-01-24 14:14:53 +000026#include "magick/string_.h"
cristy3ed852e2009-09-05 21:47:34 +000027
28#define ThrowBinaryException(severity,tag,context) \
29{ \
30 if (image != (Image *) NULL) \
31 (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \
32 tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \
33 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, \
cristy5bf97b52011-01-24 13:21:15 +000046 tag == (const char *) NULL ? "unknown" : tag,"`%s'",message); \
47 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, \
cristy5bf97b52011-01-24 13:21:15 +000059 tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \
60 message=DestroyString(message); \
cristy3ed852e2009-09-05 21:47:34 +000061}
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(&image->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