blob: 42ecb4c261b09806cc1658084cceb8f8a4f1e47d [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristy16af1cb2009-12-11 21:38:29 +00002 Copyright 1999-2010 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"
26
27#define ThrowBinaryException(severity,tag,context) \
28{ \
29 if (image != (Image *) NULL) \
30 (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \
31 tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \
32 return(MagickFalse); \
33}
34#define ThrowFatalException(severity,tag) \
35{ \
36 ExceptionInfo \
37 exception; \
38 \
39 GetExceptionInfo(&exception); \
40 (void) ThrowMagickException(&exception,GetMagickModule(),severity, \
cristy5c502622009-12-22 02:43:02 +000041 tag == (const char *) NULL ? "unknown" : tag,"`%s'", \
42 GetExceptionMessage(errno)); \
cristy3ed852e2009-09-05 21:47:34 +000043 CatchException(&exception); \
44 (void) DestroyExceptionInfo(&exception); \
45 _exit(1); \
46}
47#define ThrowFileException(exception,severity,tag,context) \
48{ \
49 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
50 tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \
cristy5c502622009-12-22 02:43:02 +000051 GetExceptionMessage(errno)); \
cristy3ed852e2009-09-05 21:47:34 +000052}
53#define ThrowImageException(severity,tag) \
54{ \
55 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
56 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \
57 return((Image *) NULL); \
58}
59#define ThrowReaderException(severity,tag) \
60{ \
61 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
62 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image_info->filename); \
63 if ((image) != (Image *) NULL) \
64 { \
65 (void) CloseBlob(image); \
66 image=DestroyImageList(image); \
67 } \
68 return((Image *) NULL); \
69}
70#define ThrowWriterException(severity,tag) \
71{ \
72 (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \
73 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \
74 if (image_info->adjoin != MagickFalse) \
75 while (image->previous != (Image *) NULL) \
76 image=image->previous; \
77 (void) CloseBlob(image); \
78 return(MagickFalse); \
79}
80
81#if defined(__cplusplus) || defined(c_plusplus)
82}
83#endif
84
85#endif