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