• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 // Copyright Dirk Lemstra 2014-2015
5 //
6 // Definition of Magick::Exception and derived classes
7 // Magick::Warning* and Magick::Error*.  Derived from C++ STD
8 // 'exception' class for convenience.
9 //
10 // These classes form part of the Magick++ user interface.
11 //
12 
13 #if !defined(Magick_Exception_header)
14 #define Magick_Exception_header
15 
16 #include "Magick++/Include.h"
17 #include <string>
18 #include <exception>
19 
20 namespace Magick
21 {
22   class MagickPPExport Exception: public std::exception
23   {
24   public:
25 
26     // Construct with message string
27     Exception(const std::string& what_);
28 
29     // Construct with message string and nested exception
30     Exception(const std::string& what_, Exception* nested_);
31 
32     // Copy constructor
33     Exception(const Exception& original_);
34 
35     // Destructor
36     virtual ~Exception() throw();
37 
38     // Assignment operator
39     Exception& operator=(const Exception& original_);
40 
41     // Get string identifying exception
42     virtual const char* what() const throw();
43 
44     // Get nested exception
45     const Exception* nested() const throw();
46 
47     //////////////////////////////////////////////////////////////////////
48     //
49     // No user-serviceable parts beyond this point
50     //
51     //////////////////////////////////////////////////////////////////////
52 
53     void nested(Exception* nested_) throw();
54 
55   private:
56     std::string _what;
57     Exception* _nested;
58   };
59 
60   //
61   // Error exceptions
62   //
63 
64   class MagickPPExport Error: public Exception
65   {
66   public:
67     explicit Error(const std::string& what_);
68     explicit Error(const std::string& what_,Exception *nested_);
69     ~Error() throw();
70   };
71 
72   class MagickPPExport ErrorBlob: public Error
73   {
74   public:
75     explicit ErrorBlob(const std::string& what_);
76     explicit ErrorBlob(const std::string& what_,Exception *nested_);
77     ~ErrorBlob() throw();
78   };
79 
80   class MagickPPExport ErrorCache: public Error
81   {
82   public:
83     explicit ErrorCache(const std::string& what_);
84     explicit ErrorCache(const std::string& what_,Exception *nested_);
85     ~ErrorCache() throw();
86   };
87 
88   class MagickPPExport ErrorCoder: public Error
89   {
90   public:
91     explicit ErrorCoder(const std::string& what_);
92     explicit ErrorCoder(const std::string& what_,Exception *nested_);
93     ~ErrorCoder() throw();
94   };
95 
96   class MagickPPExport ErrorConfigure: public Error
97   {
98   public:
99     explicit ErrorConfigure(const std::string& what_);
100     explicit ErrorConfigure(const std::string& what_,Exception *nested_);
101     ~ErrorConfigure() throw();
102   };
103 
104   class MagickPPExport ErrorCorruptImage: public Error
105   {
106   public:
107     explicit ErrorCorruptImage(const std::string& what_);
108     explicit ErrorCorruptImage(const std::string& what_,Exception *nested_);
109     ~ErrorCorruptImage() throw();
110   };
111 
112   class MagickPPExport ErrorDelegate: public Error
113   {
114   public:
115     explicit ErrorDelegate(const std::string& what_);
116     explicit ErrorDelegate(const std::string& what_,Exception *nested_);
117     ~ErrorDelegate() throw();
118   };
119 
120   class MagickPPExport ErrorDraw: public Error
121   {
122   public:
123     explicit ErrorDraw(const std::string& what_);
124     explicit ErrorDraw(const std::string& what_,Exception *nested_);
125     ~ErrorDraw() throw();
126   };
127 
128   class MagickPPExport ErrorFileOpen: public Error
129   {
130   public:
131     explicit ErrorFileOpen(const std::string& what_);
132     explicit ErrorFileOpen(const std::string& what_,Exception *nested_);
133     ~ErrorFileOpen() throw();
134   };
135 
136   class MagickPPExport ErrorImage: public Error
137   {
138   public:
139     explicit ErrorImage(const std::string& what_);
140     explicit ErrorImage(const std::string& what_,Exception *nested_);
141     ~ErrorImage() throw();
142   };
143 
144   class MagickPPExport ErrorMissingDelegate: public Error
145   {
146   public:
147     explicit ErrorMissingDelegate(const std::string& what_);
148     explicit ErrorMissingDelegate(const std::string& what_,Exception *nested_);
149     ~ErrorMissingDelegate() throw();
150   };
151 
152   class MagickPPExport ErrorModule: public Error
153   {
154   public:
155     explicit ErrorModule(const std::string& what_);
156     explicit ErrorModule(const std::string& what_,Exception *nested_);
157     ~ErrorModule() throw();
158   };
159 
160   class MagickPPExport ErrorMonitor: public Error
161   {
162   public:
163     explicit ErrorMonitor(const std::string& what_);
164     explicit ErrorMonitor(const std::string& what_,Exception *nested_);
165     ~ErrorMonitor() throw();
166   };
167 
168   class MagickPPExport ErrorOption: public Error
169   {
170   public:
171     explicit ErrorOption(const std::string& what_);
172     explicit ErrorOption(const std::string& what_,Exception *nested_);
173     ~ErrorOption() throw();
174   };
175 
176   class MagickPPExport ErrorPolicy: public Error
177   {
178   public:
179     explicit ErrorPolicy(const std::string& what_);
180     explicit ErrorPolicy(const std::string& what_,Exception *nested_);
181     ~ErrorPolicy() throw();
182   };
183 
184   class MagickPPExport ErrorRegistry: public Error
185   {
186   public:
187     explicit ErrorRegistry(const std::string& what_);
188     explicit ErrorRegistry(const std::string& what_,Exception *nested_);
189     ~ErrorRegistry() throw();
190   };
191 
192   class MagickPPExport ErrorResourceLimit: public Error
193   {
194   public:
195     explicit ErrorResourceLimit(const std::string& what_);
196     explicit ErrorResourceLimit(const std::string& what_,Exception *nested_);
197     ~ErrorResourceLimit() throw();
198   };
199 
200   class MagickPPExport ErrorStream: public Error
201   {
202   public:
203     explicit ErrorStream(const std::string& what_);
204     explicit ErrorStream(const std::string& what_,Exception *nested_);
205     ~ErrorStream() throw();
206   };
207 
208   class MagickPPExport ErrorType: public Error
209   {
210   public:
211     explicit ErrorType(const std::string& what_);
212     explicit ErrorType(const std::string& what_,Exception *nested_);
213     ~ErrorType() throw();
214   };
215 
216   class MagickPPExport ErrorUndefined: public Error
217   {
218   public:
219     explicit ErrorUndefined(const std::string& what_);
220     explicit ErrorUndefined(const std::string& what_,Exception *nested_);
221     ~ErrorUndefined() throw();
222   };
223 
224   class MagickPPExport ErrorXServer: public Error
225   {
226   public:
227     explicit ErrorXServer(const std::string& what_);
228     explicit ErrorXServer(const std::string& what_,Exception *nested_);
229     ~ErrorXServer() throw();
230   };
231 
232   //
233   // Warnings
234   //
235 
236   class MagickPPExport Warning: public Exception
237   {
238   public:
239     explicit Warning(const std::string& what_);
240     explicit Warning(const std::string& what_,Exception *nested_);
241     ~Warning() throw();
242   };
243 
244   class MagickPPExport WarningBlob: public Warning
245   {
246   public:
247     explicit WarningBlob(const std::string& what_);
248     explicit WarningBlob(const std::string& what_,Exception *nested_);
249     ~WarningBlob() throw();
250   };
251 
252   class MagickPPExport WarningCache: public Warning
253   {
254   public:
255     explicit WarningCache(const std::string& what_);
256     explicit WarningCache(const std::string& what_,Exception *nested_);
257     ~WarningCache() throw();
258   };
259 
260   class MagickPPExport WarningCoder: public Warning
261   {
262   public:
263     explicit WarningCoder(const std::string& what_);
264     explicit WarningCoder(const std::string& what_,Exception *nested_);
265     ~WarningCoder() throw();
266   };
267 
268   class MagickPPExport WarningConfigure: public Warning
269   {
270   public:
271     explicit WarningConfigure(const std::string& what_);
272     explicit WarningConfigure(const std::string& what_,Exception *nested_);
273     ~WarningConfigure() throw();
274   };
275 
276   class MagickPPExport WarningCorruptImage: public Warning
277   {
278   public:
279     explicit WarningCorruptImage(const std::string& what_);
280     explicit WarningCorruptImage(const std::string& what_,Exception *nested_);
281     ~WarningCorruptImage() throw();
282   };
283 
284   class MagickPPExport WarningDelegate: public Warning
285   {
286   public:
287     explicit WarningDelegate(const std::string& what_);
288     explicit WarningDelegate(const std::string& what_,Exception *nested_);
289     ~WarningDelegate() throw();
290   };
291 
292   class MagickPPExport WarningDraw : public Warning
293   {
294   public:
295     explicit WarningDraw(const std::string& what_);
296     explicit WarningDraw(const std::string& what_,Exception *nested_);
297     ~WarningDraw() throw();
298   };
299 
300   class MagickPPExport WarningFileOpen: public Warning
301   {
302   public:
303     explicit WarningFileOpen(const std::string& what_);
304     explicit WarningFileOpen(const std::string& what_,Exception *nested_);
305     ~WarningFileOpen() throw();
306   };
307 
308   class MagickPPExport WarningImage: public Warning
309   {
310   public:
311     explicit WarningImage(const std::string& what_);
312     explicit WarningImage(const std::string& what_,Exception *nested_);
313     ~WarningImage() throw();
314   };
315 
316   class MagickPPExport WarningMissingDelegate: public Warning
317   {
318   public:
319     explicit WarningMissingDelegate(const std::string& what_);
320     explicit WarningMissingDelegate(const std::string& what_,
321       Exception *nested_);
322     ~WarningMissingDelegate() throw();
323   };
324 
325   class MagickPPExport WarningModule: public Warning
326   {
327   public:
328     explicit WarningModule(const std::string& what_);
329     explicit WarningModule(const std::string& what_,Exception *nested_);
330     ~WarningModule() throw();
331   };
332 
333   class MagickPPExport WarningMonitor: public Warning
334   {
335   public:
336     explicit WarningMonitor(const std::string& what_);
337     explicit WarningMonitor(const std::string& what_,Exception *nested_);
338     ~WarningMonitor() throw();
339   };
340 
341   class MagickPPExport WarningOption: public Warning
342   {
343   public:
344     explicit WarningOption(const std::string& what_);
345     explicit WarningOption(const std::string& what_,Exception *nested_);
346     ~WarningOption() throw();
347   };
348 
349   class MagickPPExport WarningPolicy: public Warning
350   {
351   public:
352     explicit WarningPolicy(const std::string& what_);
353     explicit WarningPolicy(const std::string& what_,Exception *nested_);
354     ~WarningPolicy() throw();
355   };
356 
357   class MagickPPExport WarningRegistry: public Warning
358   {
359   public:
360     explicit WarningRegistry(const std::string& what_);
361     explicit WarningRegistry(const std::string& what_,Exception *nested_);
362     ~WarningRegistry() throw();
363   };
364 
365   class MagickPPExport WarningResourceLimit: public Warning
366   {
367   public:
368     explicit WarningResourceLimit(const std::string& what_);
369     explicit WarningResourceLimit(const std::string& what_,Exception *nested_);
370     ~WarningResourceLimit() throw();
371   };
372 
373   class MagickPPExport WarningStream: public Warning
374   {
375   public:
376     explicit WarningStream(const std::string& what_);
377     explicit WarningStream(const std::string& what_,Exception *nested_);
378     ~WarningStream() throw();
379   };
380 
381   class MagickPPExport WarningType: public Warning
382   {
383   public:
384     explicit WarningType(const std::string& what_);
385     explicit WarningType(const std::string& what_,Exception *nested_);
386     ~WarningType() throw();
387   };
388 
389   class MagickPPExport WarningUndefined: public Warning
390   {
391   public:
392     explicit WarningUndefined(const std::string& what_);
393     explicit WarningUndefined(const std::string& what_,Exception *nested_);
394     ~WarningUndefined() throw();
395   };
396 
397   class MagickPPExport WarningXServer: public Warning
398   {
399   public:
400     explicit WarningXServer(const std::string& what_);
401     explicit WarningXServer(const std::string& what_,Exception *nested_);
402     ~WarningXServer() throw();
403   };
404 
405   //
406   // No user-serviceable components beyond this point.
407   //
408 
409   std::string formatExceptionMessage(
410     const MagickCore::ExceptionInfo *exception_);
411 
412   Exception* createException(const MagickCore::ExceptionInfo *exception_);
413 
414   // Throw exception based on raw data
415   extern MagickPPExport void throwExceptionExplicit(
416     const MagickCore::ExceptionType severity_,const char* reason_,
417     const char* description_=(char *) NULL);
418 
419   // Thow exception based on ImageMagick's ExceptionInfo
420   extern MagickPPExport void throwException(
421     MagickCore::ExceptionInfo *exception_,const bool quiet_=false);
422 
423 } // namespace Magick
424 
425 #endif // Magick_Exception_header
426