blob: a10cfeecadc2545af01a2382dcc97db0baee0d52 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
cristyb56bb242014-11-25 17:12:48 +00002 Copyright 1999-2015 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
cristy4c08aed2011-07-01 19:47:50 +000021#include "MagickCore/log.h"
cristy8ed60112012-12-13 14:56:15 +000022#include "MagickCore/magick.h"
cristy4c08aed2011-07-01 19:47:50 +000023#include "MagickCore/string_.h"
cristy3ed852e2009-09-05 21:47:34 +000024
cristy6398ec72013-11-28 02:00:27 +000025#if defined(__cplusplus) || defined(c_plusplus)
26extern "C" {
27#endif
28
cristy3ed852e2009-09-05 21:47:34 +000029#define ThrowBinaryException(severity,tag,context) \
30{ \
31 if (image != (Image *) NULL) \
cristy018f07f2011-09-04 21:15:19 +000032 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
cristyefe601c2013-01-05 17:51:12 +000033 tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \
cristy3ed852e2009-09-05 21:47:34 +000034 return(MagickFalse); \
35}
36#define ThrowFatalException(severity,tag) \
37{ \
cristy5bf97b52011-01-24 13:21:15 +000038 char \
39 *message; \
40 \
cristy3ed852e2009-09-05 21:47:34 +000041 ExceptionInfo \
dirke31feb82014-06-20 11:03:07 +000042 *exception; \
cristy3ed852e2009-09-05 21:47:34 +000043 \
dirke31feb82014-06-20 11:03:07 +000044 exception=AcquireExceptionInfo(); \
cristy5bf97b52011-01-24 13:21:15 +000045 message=GetExceptionMessage(errno); \
dirke31feb82014-06-20 11:03:07 +000046 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
cristyefe601c2013-01-05 17:51:12 +000047 tag == (const char *) NULL ? "unknown" : tag,"`%s'",message); \
cristy5bf97b52011-01-24 13:21:15 +000048 message=DestroyString(message); \
dirke31feb82014-06-20 11:03:07 +000049 CatchException(exception); \
50 (void) DestroyExceptionInfo(exception); \
cristy8ed60112012-12-13 14:56:15 +000051 MagickCoreTerminus(); \
cristyb4d552c2012-12-13 15:42:17 +000052 _exit((int) (severity-FatalErrorException)+1); \
cristy3ed852e2009-09-05 21:47:34 +000053}
54#define ThrowFileException(exception,severity,tag,context) \
55{ \
cristy5bf97b52011-01-24 13:21:15 +000056 char \
57 *message; \
58 \
59 message=GetExceptionMessage(errno); \
cristy3ed852e2009-09-05 21:47:34 +000060 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
anthonye5b39652012-04-21 05:37:29 +000061 tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context,message); \
cristy5bf97b52011-01-24 13:21:15 +000062 message=DestroyString(message); \
cristy3ed852e2009-09-05 21:47:34 +000063}
64#define ThrowImageException(severity,tag) \
65{ \
66 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
cristyefe601c2013-01-05 17:51:12 +000067 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \
cristy3ed852e2009-09-05 21:47:34 +000068 return((Image *) NULL); \
69}
70#define ThrowReaderException(severity,tag) \
71{ \
72 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
cristyefe601c2013-01-05 17:51:12 +000073 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image_info->filename); \
cristy3ed852e2009-09-05 21:47:34 +000074 if ((image) != (Image *) NULL) \
75 { \
76 (void) CloseBlob(image); \
77 image=DestroyImageList(image); \
78 } \
79 return((Image *) NULL); \
80}
81#define ThrowWriterException(severity,tag) \
82{ \
cristy018f07f2011-09-04 21:15:19 +000083 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
cristyefe601c2013-01-05 17:51:12 +000084 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \
cristy3ed852e2009-09-05 21:47:34 +000085 if (image_info->adjoin != MagickFalse) \
86 while (image->previous != (Image *) NULL) \
87 image=image->previous; \
88 (void) CloseBlob(image); \
89 return(MagickFalse); \
90}
91
dirke31feb82014-06-20 11:03:07 +000092extern MagickPrivate void
93 InitializeExceptionInfo(ExceptionInfo *);
94
cristy3ed852e2009-09-05 21:47:34 +000095#if defined(__cplusplus) || defined(c_plusplus)
96}
97#endif
98
99#endif