blob: db61aa0a6c27446b12261d68fe1097ce3e9388b8 [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 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>
26#include "magick/semaphore.h"
27
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
123 unsigned long
124 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),
147 *DestroyExceptionInfo(ExceptionInfo *);
148
149extern MagickExport FatalErrorHandler
150 SetFatalErrorHandler(FatalErrorHandler);
151
152extern MagickExport MagickBooleanType
153 ThrowException(ExceptionInfo *,const ExceptionType,const char *,
154 const char *),
155 ThrowMagickException(ExceptionInfo *,const char *,const char *,
156 const unsigned long,const ExceptionType,const char *,const char *,...)
157 magick_attribute((format (printf,7,8))),
158 ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *,
159 const unsigned long,const ExceptionType,const char *,const char *,va_list)
160 magick_attribute((format (printf,7,0)));
161
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