blob: 581c035b115d2eab2f400a0ae27d0a4c7f29a35f [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 methods.
17*/
18#ifndef _MAGICKCORE_EXCEPTION_H
19#define _MAGICKCORE_EXCEPTION_H
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
25#include <stdarg.h>
cristy4c08aed2011-07-01 19:47:50 +000026#include "MagickCore/semaphore.h"
cristy3ed852e2009-09-05 21:47:34 +000027
28typedef enum
29{
30 UndefinedException,
31 WarningException = 300,
32 ResourceLimitWarning = 300,
33 TypeWarning = 305,
34 OptionWarning = 310,
35 DelegateWarning = 315,
36 MissingDelegateWarning = 320,
37 CorruptImageWarning = 325,
38 FileOpenWarning = 330,
39 BlobWarning = 335,
40 StreamWarning = 340,
41 CacheWarning = 345,
42 CoderWarning = 350,
cristy992729d2010-01-01 15:45:06 +000043 FilterWarning = 352,
cristy3ed852e2009-09-05 21:47:34 +000044 ModuleWarning = 355,
45 DrawWarning = 360,
46 ImageWarning = 365,
47 WandWarning = 370,
48 RandomWarning = 375,
49 XServerWarning = 380,
50 MonitorWarning = 385,
51 RegistryWarning = 390,
52 ConfigureWarning = 395,
53 PolicyWarning = 399,
54 ErrorException = 400,
55 ResourceLimitError = 400,
56 TypeError = 405,
57 OptionError = 410,
58 DelegateError = 415,
59 MissingDelegateError = 420,
60 CorruptImageError = 425,
61 FileOpenError = 430,
62 BlobError = 435,
63 StreamError = 440,
64 CacheError = 445,
65 CoderError = 450,
cristy992729d2010-01-01 15:45:06 +000066 FilterError = 452,
cristy3ed852e2009-09-05 21:47:34 +000067 ModuleError = 455,
68 DrawError = 460,
69 ImageError = 465,
70 WandError = 470,
71 RandomError = 475,
72 XServerError = 480,
73 MonitorError = 485,
74 RegistryError = 490,
75 ConfigureError = 495,
76 PolicyError = 499,
77 FatalErrorException = 700,
78 ResourceLimitFatalError = 700,
79 TypeFatalError = 705,
80 OptionFatalError = 710,
81 DelegateFatalError = 715,
82 MissingDelegateFatalError = 720,
83 CorruptImageFatalError = 725,
84 FileOpenFatalError = 730,
85 BlobFatalError = 735,
86 StreamFatalError = 740,
87 CacheFatalError = 745,
88 CoderFatalError = 750,
cristy992729d2010-01-01 15:45:06 +000089 FilterFatalError = 752,
cristy3ed852e2009-09-05 21:47:34 +000090 ModuleFatalError = 755,
91 DrawFatalError = 760,
92 ImageFatalError = 765,
93 WandFatalError = 770,
94 RandomFatalError = 775,
95 XServerFatalError = 780,
96 MonitorFatalError = 785,
97 RegistryFatalError = 790,
98 ConfigureFatalError = 795,
99 PolicyFatalError = 799
100} ExceptionType;
101
102struct _ExceptionInfo
103{
104 ExceptionType
105 severity;
106
107 int
108 error_number;
109
110 char
111 *reason,
112 *description;
113
114 void
115 *exceptions;
116
117 MagickBooleanType
118 relinquish;
119
120 SemaphoreInfo
121 *semaphore;
122
cristybb503372010-05-27 20:51:26 +0000123 size_t
cristy3ed852e2009-09-05 21:47:34 +0000124 signature;
125};
126
127typedef void
128 (*ErrorHandler)(const ExceptionType,const char *,const char *);
129
130typedef void
131 (*FatalErrorHandler)(const ExceptionType,const char *,const char *);
132
133typedef void
134 (*WarningHandler)(const ExceptionType,const char *,const char *);
135
136extern MagickExport char
137 *GetExceptionMessage(const int);
138
139extern MagickExport const char
140 *GetLocaleExceptionMessage(const ExceptionType,const char *);
141
142extern MagickExport ErrorHandler
143 SetErrorHandler(ErrorHandler);
144
145extern MagickExport ExceptionInfo
146 *AcquireExceptionInfo(void),
cristyc82a27b2011-10-21 01:07:16 +0000147 *CloneExceptionInfo(ExceptionInfo *),
cristy3ed852e2009-09-05 21:47:34 +0000148 *DestroyExceptionInfo(ExceptionInfo *);
149
150extern MagickExport FatalErrorHandler
151 SetFatalErrorHandler(FatalErrorHandler);
152
153extern MagickExport MagickBooleanType
154 ThrowException(ExceptionInfo *,const ExceptionType,const char *,
155 const char *),
anthony5216f822012-04-10 13:02:37 +0000156 ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *,const size_t,
157 const ExceptionType,const char *,const char *,va_list),
cristy5ed838e2010-05-31 00:05:35 +0000158 ThrowMagickException(ExceptionInfo *,const char *,const char *,const size_t,
159 const ExceptionType,const char *,const char *,...)
cristy73380532012-02-18 20:26:28 +0000160 magick_attribute((__format__ (__printf__,7,8)));
cristy3ed852e2009-09-05 21:47:34 +0000161
162extern MagickExport void
163 CatchException(ExceptionInfo *),
164 ClearMagickException(ExceptionInfo *),
165 GetExceptionInfo(ExceptionInfo *),
166 InheritException(ExceptionInfo *,const ExceptionInfo *),
167 MagickError(const ExceptionType,const char *,const char *),
168 MagickFatalError(const ExceptionType,const char *,const char *),
169 MagickWarning(const ExceptionType,const char *,const char *);
170
171extern MagickExport WarningHandler
172 SetWarningHandler(WarningHandler);
173
174#if defined(__cplusplus) || defined(c_plusplus)
175}
176#endif
177
178#endif