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-2017
5 //
6 // Implementation of Exception and derived classes
7 //
8
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11
12 #include "Magick++/Include.h"
13 #include <string>
14 #include <errno.h>
15 #include <string.h>
16
17 using namespace std;
18
19 #include "Magick++/Exception.h"
20
Exception(const std::string & what_)21 Magick::Exception::Exception(const std::string& what_)
22 : std::exception(),
23 _what(what_),
24 _nested((Exception *) NULL)
25 {
26 }
27
Exception(const std::string & what_,Exception * nested_)28 Magick::Exception::Exception(const std::string& what_,
29 Exception* nested_)
30 : std::exception(),
31 _what(what_),
32 _nested(nested_)
33 {
34 }
35
Exception(const Magick::Exception & original_)36 Magick::Exception::Exception(const Magick::Exception& original_)
37 : exception(original_),
38 _what(original_._what),
39 _nested((Exception *) NULL)
40 {
41 }
42
~Exception()43 Magick::Exception::~Exception() throw()
44 {
45 delete _nested;
46 }
47
operator =(const Magick::Exception & original_)48 Magick::Exception& Magick::Exception::operator=(
49 const Magick::Exception& original_)
50 {
51 if (this != &original_)
52 this->_what=original_._what;
53 return(*this);
54 }
55
what() const56 const char* Magick::Exception::what() const throw()
57 {
58 return(_what.c_str());
59 }
60
nested() const61 const Magick::Exception* Magick::Exception::nested() const throw()
62 {
63 return(_nested);
64 }
65
nested(Exception * nested_)66 void Magick::Exception::nested(Exception* nested_) throw()
67 {
68 _nested=nested_;
69 }
70
Error(const std::string & what_)71 Magick::Error::Error(const std::string& what_)
72 : Exception(what_)
73 {
74 }
75
Error(const std::string & what_,Exception * nested_)76 Magick::Error::Error(const std::string& what_,Exception *nested_)
77 : Exception(what_,nested_)
78 {
79 }
80
~Error()81 Magick::Error::~Error() throw()
82 {
83 }
84
ErrorBlob(const std::string & what_)85 Magick::ErrorBlob::ErrorBlob(const std::string& what_)
86 : Error(what_)
87 {
88 }
89
ErrorBlob(const std::string & what_,Exception * nested_)90 Magick::ErrorBlob::ErrorBlob(const std::string& what_,Exception *nested_)
91 : Error(what_,nested_)
92 {
93 }
94
~ErrorBlob()95 Magick::ErrorBlob::~ErrorBlob() throw()
96 {
97 }
98
ErrorCache(const std::string & what_)99 Magick::ErrorCache::ErrorCache(const std::string& what_)
100 : Error(what_)
101 {
102 }
103
ErrorCache(const std::string & what_,Exception * nested_)104 Magick::ErrorCache::ErrorCache(const std::string& what_,Exception *nested_)
105 : Error(what_,nested_)
106 {
107 }
108
~ErrorCache()109 Magick::ErrorCache::~ErrorCache() throw()
110 {
111 }
112
ErrorCoder(const std::string & what_)113 Magick::ErrorCoder::ErrorCoder(const std::string& what_)
114 : Error(what_)
115 {
116 }
117
ErrorCoder(const std::string & what_,Exception * nested_)118 Magick::ErrorCoder::ErrorCoder(const std::string& what_,Exception *nested_)
119 : Error(what_,nested_)
120 {
121 }
122
~ErrorCoder()123 Magick::ErrorCoder::~ErrorCoder() throw()
124 {
125 }
126
ErrorConfigure(const std::string & what_)127 Magick::ErrorConfigure::ErrorConfigure(const std::string& what_)
128 : Error(what_)
129 {
130 }
131
ErrorConfigure(const std::string & what_,Exception * nested_)132 Magick::ErrorConfigure::ErrorConfigure(const std::string& what_,
133 Exception *nested_)
134 : Error(what_,nested_)
135 {
136 }
137
~ErrorConfigure()138 Magick::ErrorConfigure::~ErrorConfigure() throw()
139 {
140 }
141
ErrorCorruptImage(const std::string & what_)142 Magick::ErrorCorruptImage::ErrorCorruptImage(const std::string& what_)
143 : Error(what_)
144 {
145 }
146
ErrorCorruptImage(const std::string & what_,Exception * nested_)147 Magick::ErrorCorruptImage::ErrorCorruptImage(const std::string& what_,
148 Exception *nested_)
149 : Error(what_,nested_)
150 {
151 }
152
~ErrorCorruptImage()153 Magick::ErrorCorruptImage::~ErrorCorruptImage() throw()
154 {
155 }
156
ErrorDelegate(const std::string & what_)157 Magick::ErrorDelegate::ErrorDelegate(const std::string& what_)
158 : Error(what_)
159 {
160 }
161
ErrorDelegate(const std::string & what_,Exception * nested_)162 Magick::ErrorDelegate::ErrorDelegate(const std::string& what_,
163 Exception *nested_)
164 : Error(what_,nested_)
165 {
166 }
167
~ErrorDelegate()168 Magick::ErrorDelegate::~ErrorDelegate()throw()
169 {
170 }
171
ErrorDraw(const std::string & what_)172 Magick::ErrorDraw::ErrorDraw(const std::string& what_)
173 : Error(what_)
174 {
175 }
176
ErrorDraw(const std::string & what_,Exception * nested_)177 Magick::ErrorDraw::ErrorDraw(const std::string& what_,Exception *nested_)
178 : Error(what_,nested_)
179 {
180 }
181
~ErrorDraw()182 Magick::ErrorDraw::~ErrorDraw() throw()
183 {
184 }
185
ErrorFileOpen(const std::string & what_)186 Magick::ErrorFileOpen::ErrorFileOpen(const std::string& what_)
187 : Error(what_)
188 {
189 }
190
~ErrorFileOpen()191 Magick::ErrorFileOpen::~ErrorFileOpen() throw()
192 {
193 }
194
ErrorFileOpen(const std::string & what_,Exception * nested_)195 Magick::ErrorFileOpen::ErrorFileOpen(const std::string& what_,
196 Exception *nested_)
197 : Error(what_,nested_)
198 {
199 }
200
201
ErrorImage(const std::string & what_)202 Magick::ErrorImage::ErrorImage(const std::string& what_)
203 : Error(what_)
204 {
205 }
206
ErrorImage(const std::string & what_,Exception * nested_)207 Magick::ErrorImage::ErrorImage(const std::string& what_,Exception *nested_)
208 : Error(what_,nested_)
209 {
210 }
211
~ErrorImage()212 Magick::ErrorImage::~ErrorImage() throw()
213 {
214 }
215
ErrorMissingDelegate(const std::string & what_)216 Magick::ErrorMissingDelegate::ErrorMissingDelegate(const std::string& what_)
217 : Error(what_)
218 {
219 }
220
ErrorMissingDelegate(const std::string & what_,Exception * nested_)221 Magick::ErrorMissingDelegate::ErrorMissingDelegate(const std::string& what_,
222 Exception *nested_)
223 : Error(what_,nested_)
224 {
225 }
226
~ErrorMissingDelegate()227 Magick::ErrorMissingDelegate::~ErrorMissingDelegate() throw ()
228 {
229 }
230
ErrorModule(const std::string & what_)231 Magick::ErrorModule::ErrorModule(const std::string& what_)
232 : Error(what_)
233 {
234 }
235
ErrorModule(const std::string & what_,Exception * nested_)236 Magick::ErrorModule::ErrorModule(const std::string& what_,Exception *nested_)
237 : Error(what_,nested_)
238 {
239 }
240
~ErrorModule()241 Magick::ErrorModule::~ErrorModule() throw()
242 {
243 }
244
ErrorMonitor(const std::string & what_)245 Magick::ErrorMonitor::ErrorMonitor(const std::string& what_)
246 : Error(what_)
247 {
248 }
249
ErrorMonitor(const std::string & what_,Exception * nested_)250 Magick::ErrorMonitor::ErrorMonitor(const std::string& what_,Exception *nested_)
251 : Error(what_,nested_)
252 {
253 }
254
~ErrorMonitor()255 Magick::ErrorMonitor::~ErrorMonitor() throw()
256 {
257 }
258
ErrorOption(const std::string & what_)259 Magick::ErrorOption::ErrorOption(const std::string& what_)
260 : Error(what_)
261 {
262 }
263
ErrorOption(const std::string & what_,Exception * nested_)264 Magick::ErrorOption::ErrorOption(const std::string& what_,Exception *nested_)
265 : Error(what_,nested_)
266 {
267 }
268
~ErrorOption()269 Magick::ErrorOption::~ErrorOption() throw()
270 {
271 }
272
ErrorPolicy(const std::string & what_)273 Magick::ErrorPolicy::ErrorPolicy(const std::string& what_)
274 : Error(what_)
275 {
276 }
277
ErrorPolicy(const std::string & what_,Exception * nested_)278 Magick::ErrorPolicy::ErrorPolicy(const std::string& what_,Exception *nested_)
279 : Error(what_,nested_)
280 {
281 }
282
~ErrorPolicy()283 Magick::ErrorPolicy::~ErrorPolicy() throw()
284 {
285 }
286
287
ErrorRegistry(const std::string & what_)288 Magick::ErrorRegistry::ErrorRegistry(const std::string& what_)
289 : Error(what_)
290 {
291 }
292
ErrorRegistry(const std::string & what_,Exception * nested_)293 Magick::ErrorRegistry::ErrorRegistry(const std::string& what_,
294 Exception *nested_)
295 : Error(what_,nested_)
296 {
297 }
298
~ErrorRegistry()299 Magick::ErrorRegistry::~ErrorRegistry() throw()
300 {
301 }
302
ErrorResourceLimit(const std::string & what_)303 Magick::ErrorResourceLimit::ErrorResourceLimit(const std::string& what_)
304 : Error(what_)
305 {
306 }
307
ErrorResourceLimit(const std::string & what_,Exception * nested_)308 Magick::ErrorResourceLimit::ErrorResourceLimit(const std::string& what_,
309 Exception *nested_)
310 : Error(what_,nested_)
311 {
312 }
313
~ErrorResourceLimit()314 Magick::ErrorResourceLimit::~ErrorResourceLimit() throw()
315 {
316 }
317
ErrorStream(const std::string & what_)318 Magick::ErrorStream::ErrorStream(const std::string& what_)
319 : Error(what_)
320 {
321 }
322
ErrorStream(const std::string & what_,Exception * nested_)323 Magick::ErrorStream::ErrorStream(const std::string& what_,Exception *nested_)
324 : Error(what_,nested_)
325 {
326 }
327
~ErrorStream()328 Magick::ErrorStream::~ErrorStream() throw()
329 {
330 }
331
ErrorType(const std::string & what_)332 Magick::ErrorType::ErrorType(const std::string& what_)
333 : Error(what_)
334 {
335 }
336
ErrorType(const std::string & what_,Exception * nested_)337 Magick::ErrorType::ErrorType(const std::string& what_,Exception *nested_)
338 : Error(what_,nested_)
339 {
340 }
341
~ErrorType()342 Magick::ErrorType::~ErrorType() throw()
343 {
344 }
345
ErrorUndefined(const std::string & what_)346 Magick::ErrorUndefined::ErrorUndefined(const std::string& what_)
347 : Error(what_)
348 {
349 }
350
ErrorUndefined(const std::string & what_,Exception * nested_)351 Magick::ErrorUndefined::ErrorUndefined(const std::string& what_,
352 Exception *nested_)
353 : Error(what_,nested_)
354 {
355 }
356
~ErrorUndefined()357 Magick::ErrorUndefined::~ErrorUndefined() throw()
358 {
359 }
360
ErrorXServer(const std::string & what_)361 Magick::ErrorXServer::ErrorXServer(const std::string& what_)
362 : Error(what_)
363 {
364 }
365
ErrorXServer(const std::string & what_,Exception * nested_)366 Magick::ErrorXServer::ErrorXServer(const std::string& what_,Exception *nested_)
367 : Error(what_,nested_)
368 {
369 }
370
~ErrorXServer()371 Magick::ErrorXServer::~ErrorXServer() throw ()
372 {
373 }
374
Warning(const std::string & what_)375 Magick::Warning::Warning(const std::string& what_)
376 : Exception(what_)
377 {
378 }
379
Warning(const std::string & what_,Exception * nested_)380 Magick::Warning::Warning(const std::string& what_,Exception *nested_)
381 : Exception(what_,nested_)
382 {
383 }
384
~Warning()385 Magick::Warning::~Warning() throw()
386 {
387 }
388
WarningBlob(const std::string & what_)389 Magick::WarningBlob::WarningBlob(const std::string& what_)
390 : Warning(what_)
391 {
392 }
393
WarningBlob(const std::string & what_,Exception * nested_)394 Magick::WarningBlob::WarningBlob(const std::string& what_,Exception *nested_)
395 : Warning(what_,nested_)
396 {
397 }
398
~WarningBlob()399 Magick::WarningBlob::~WarningBlob() throw()
400 {
401 }
402
WarningCache(const std::string & what_)403 Magick::WarningCache::WarningCache(const std::string& what_)
404 : Warning(what_)
405 {
406 }
407
WarningCache(const std::string & what_,Exception * nested_)408 Magick::WarningCache::WarningCache(const std::string& what_,Exception *nested_)
409 : Warning(what_,nested_)
410 {
411 }
412
~WarningCache()413 Magick::WarningCache::~WarningCache() throw()
414 {
415 }
416
WarningCoder(const std::string & what_)417 Magick::WarningCoder::WarningCoder(const std::string& what_)
418 : Warning(what_)
419 {
420 }
421
WarningCoder(const std::string & what_,Exception * nested_)422 Magick::WarningCoder::WarningCoder(const std::string& what_,Exception *nested_)
423 : Warning(what_,nested_)
424 {
425 }
426
~WarningCoder()427 Magick::WarningCoder::~WarningCoder() throw()
428 {
429 }
430
WarningConfigure(const std::string & what_)431 Magick::WarningConfigure::WarningConfigure(const std::string& what_)
432 : Warning(what_)
433 {
434 }
435
WarningConfigure(const std::string & what_,Exception * nested_)436 Magick::WarningConfigure::WarningConfigure(const std::string& what_,
437 Exception *nested_)
438 : Warning(what_,nested_)
439 {
440 }
441
~WarningConfigure()442 Magick::WarningConfigure::~WarningConfigure() throw()
443 {
444 }
445
WarningCorruptImage(const std::string & what_)446 Magick::WarningCorruptImage::WarningCorruptImage(const std::string& what_)
447 : Warning(what_)
448 {
449 }
450
WarningCorruptImage(const std::string & what_,Exception * nested_)451 Magick::WarningCorruptImage::WarningCorruptImage(const std::string& what_,
452 Exception *nested_)
453 : Warning(what_,nested_)
454 {
455 }
456
~WarningCorruptImage()457 Magick::WarningCorruptImage::~WarningCorruptImage() throw()
458 {
459 }
460
WarningDelegate(const std::string & what_)461 Magick::WarningDelegate::WarningDelegate(const std::string& what_)
462 : Warning(what_)
463 {
464 }
465
WarningDelegate(const std::string & what_,Exception * nested_)466 Magick::WarningDelegate::WarningDelegate(const std::string& what_,
467 Exception *nested_)
468 : Warning(what_,nested_)
469 {
470 }
471
~WarningDelegate()472 Magick::WarningDelegate::~WarningDelegate() throw()
473 {
474 }
475
WarningDraw(const std::string & what_)476 Magick::WarningDraw::WarningDraw(const std::string& what_)
477 : Warning(what_)
478 {
479 }
480
WarningDraw(const std::string & what_,Exception * nested_)481 Magick::WarningDraw::WarningDraw(const std::string& what_,Exception *nested_)
482 : Warning(what_,nested_)
483 {
484 }
485
~WarningDraw()486 Magick::WarningDraw::~WarningDraw() throw()
487 {
488 }
489
WarningFileOpen(const std::string & what_)490 Magick::WarningFileOpen::WarningFileOpen(const std::string& what_)
491 : Warning(what_)
492 {
493 }
494
WarningFileOpen(const std::string & what_,Exception * nested_)495 Magick::WarningFileOpen::WarningFileOpen(const std::string& what_,
496 Exception *nested_)
497 : Warning(what_,nested_)
498 {
499 }
500
~WarningFileOpen()501 Magick::WarningFileOpen::~WarningFileOpen() throw()
502 {
503 }
504
WarningImage(const std::string & what_)505 Magick::WarningImage::WarningImage(const std::string& what_)
506 : Warning(what_)
507 {
508 }
509
WarningImage(const std::string & what_,Exception * nested_)510 Magick::WarningImage::WarningImage(const std::string& what_,Exception *nested_)
511 : Warning(what_,nested_)
512 {
513 }
514
~WarningImage()515 Magick::WarningImage::~WarningImage() throw()
516 {
517 }
518
WarningMissingDelegate(const std::string & what_)519 Magick::WarningMissingDelegate::WarningMissingDelegate(
520 const std::string& what_)
521 : Warning(what_)
522 {
523 }
524
WarningMissingDelegate(const std::string & what_,Exception * nested_)525 Magick::WarningMissingDelegate::WarningMissingDelegate(
526 const std::string& what_,Exception *nested_)
527 : Warning(what_,nested_)
528 {
529 }
530
~WarningMissingDelegate()531 Magick::WarningMissingDelegate::~WarningMissingDelegate() throw()
532 {
533 }
534
WarningModule(const std::string & what_)535 Magick::WarningModule::WarningModule(const std::string& what_)
536 : Warning(what_)
537 {
538 }
539
WarningModule(const std::string & what_,Exception * nested_)540 Magick::WarningModule::WarningModule(const std::string& what_,
541 Exception *nested_)
542 : Warning(what_,nested_)
543 {
544 }
545
546
~WarningModule()547 Magick::WarningModule::~WarningModule() throw()
548 {
549 }
550
WarningMonitor(const std::string & what_)551 Magick::WarningMonitor::WarningMonitor(const std::string& what_)
552 : Warning(what_)
553 {
554 }
555
WarningMonitor(const std::string & what_,Exception * nested_)556 Magick::WarningMonitor::WarningMonitor(const std::string& what_,
557 Exception *nested_)
558 : Warning(what_,nested_)
559 {
560 }
561
~WarningMonitor()562 Magick::WarningMonitor::~WarningMonitor() throw()
563 {
564 }
565
WarningOption(const std::string & what_)566 Magick::WarningOption::WarningOption(const std::string& what_)
567 : Warning(what_)
568 {
569 }
570
WarningOption(const std::string & what_,Exception * nested_)571 Magick::WarningOption::WarningOption(const std::string& what_,
572 Exception *nested_)
573 : Warning(what_,nested_)
574 {
575 }
576
~WarningOption()577 Magick::WarningOption::~WarningOption() throw()
578 {
579 }
580
WarningRegistry(const std::string & what_)581 Magick::WarningRegistry::WarningRegistry(const std::string& what_)
582 : Warning(what_)
583 {
584 }
585
WarningRegistry(const std::string & what_,Exception * nested_)586 Magick::WarningRegistry::WarningRegistry(const std::string& what_,
587 Exception *nested_)
588 : Warning(what_,nested_)
589 {
590 }
591
~WarningRegistry()592 Magick::WarningRegistry::~WarningRegistry() throw()
593 {
594 }
595
WarningPolicy(const std::string & what_)596 Magick::WarningPolicy::WarningPolicy(const std::string& what_)
597 : Warning(what_)
598 {
599 }
600
WarningPolicy(const std::string & what_,Exception * nested_)601 Magick::WarningPolicy::WarningPolicy(const std::string& what_,
602 Exception *nested_)
603 : Warning(what_,nested_)
604 {
605 }
606
~WarningPolicy()607 Magick::WarningPolicy::~WarningPolicy() throw()
608 {
609 }
610
WarningResourceLimit(const std::string & what_)611 Magick::WarningResourceLimit::WarningResourceLimit(const std::string& what_)
612 : Warning(what_)
613 {
614 }
615
WarningResourceLimit(const std::string & what_,Exception * nested_)616 Magick::WarningResourceLimit::WarningResourceLimit(const std::string& what_,
617 Exception *nested_)
618 : Warning(what_,nested_)
619 {
620 }
621
~WarningResourceLimit()622 Magick::WarningResourceLimit::~WarningResourceLimit() throw()
623 {
624 }
625
WarningStream(const std::string & what_)626 Magick::WarningStream::WarningStream(const std::string& what_)
627 : Warning(what_)
628 {
629 }
630
WarningStream(const std::string & what_,Exception * nested_)631 Magick::WarningStream::WarningStream(const std::string& what_,
632 Exception *nested_)
633 : Warning(what_,nested_)
634 {
635 }
636
~WarningStream()637 Magick::WarningStream::~WarningStream() throw()
638 {
639 }
640
WarningType(const std::string & what_)641 Magick::WarningType::WarningType(const std::string& what_)
642 : Warning(what_)
643 {
644 }
645
WarningType(const std::string & what_,Exception * nested_)646 Magick::WarningType::WarningType(const std::string& what_,Exception *nested_)
647 : Warning(what_,nested_)
648 {
649 }
650
~WarningType()651 Magick::WarningType::~WarningType() throw()
652 {
653 }
654
WarningUndefined(const std::string & what_)655 Magick::WarningUndefined::WarningUndefined(const std::string& what_)
656 : Warning(what_)
657 {
658 }
659
WarningUndefined(const std::string & what_,Exception * nested_)660 Magick::WarningUndefined::WarningUndefined(const std::string& what_,
661 Exception *nested_)
662 : Warning(what_,nested_)
663 {
664 }
665
~WarningUndefined()666 Magick::WarningUndefined::~WarningUndefined() throw()
667 {
668 }
669
WarningXServer(const std::string & what_)670 Magick::WarningXServer::WarningXServer(const std::string& what_)
671 : Warning(what_)
672 {
673 }
674
WarningXServer(const std::string & what_,Exception * nested_)675 Magick::WarningXServer::WarningXServer(const std::string& what_,
676 Exception *nested_)
677 : Warning(what_,nested_)
678 {
679 }
680
~WarningXServer()681 Magick::WarningXServer::~WarningXServer() throw()
682 {
683 }
684
formatExceptionMessage(const MagickCore::ExceptionInfo * exception_)685 std::string Magick::formatExceptionMessage(const MagickCore::ExceptionInfo *exception_)
686 {
687 // Format error message ImageMagick-style
688 std::string message=GetClientName();
689 if (exception_->reason != (char *) NULL)
690 {
691 message+=std::string(": ");
692 message+=std::string(exception_->reason);
693 }
694
695 if (exception_->description != (char *) NULL)
696 message += " (" + std::string(exception_->description) + ")";
697 return(message);
698 }
699
createException(const MagickCore::ExceptionInfo * exception_)700 Magick::Exception* Magick::createException(const MagickCore::ExceptionInfo *exception_)
701 {
702 std::string message=formatExceptionMessage(exception_);
703 switch (exception_->severity)
704 {
705 case MagickCore::BlobError:
706 case MagickCore::BlobFatalError:
707 return new ErrorBlob(message);
708 case MagickCore::BlobWarning:
709 return new WarningBlob(message);
710 case MagickCore::CacheError:
711 case MagickCore::CacheFatalError:
712 return new ErrorCache(message);
713 case MagickCore::CacheWarning:
714 return new WarningCache(message);
715 case MagickCore::CoderError:
716 case MagickCore::CoderFatalError:
717 return new ErrorCoder(message);
718 case MagickCore::CoderWarning:
719 return new WarningCoder(message);
720 case MagickCore::ConfigureError:
721 case MagickCore::ConfigureFatalError:
722 return new ErrorConfigure(message);
723 case MagickCore::ConfigureWarning:
724 return new WarningConfigure(message);
725 case MagickCore::CorruptImageError:
726 case MagickCore::CorruptImageFatalError:
727 return new ErrorCorruptImage(message);
728 case MagickCore::CorruptImageWarning:
729 return new WarningCorruptImage(message);
730 case MagickCore::DelegateError:
731 case MagickCore::DelegateFatalError:
732 return new ErrorDelegate(message);
733 case MagickCore::DelegateWarning:
734 return new WarningDelegate(message);
735 case MagickCore::DrawError:
736 case MagickCore::DrawFatalError:
737 return new ErrorDraw(message);
738 case MagickCore::DrawWarning:
739 return new WarningDraw(message);
740 case MagickCore::FileOpenError:
741 case MagickCore::FileOpenFatalError:
742 return new ErrorFileOpen(message);
743 case MagickCore::FileOpenWarning:
744 return new WarningFileOpen(message);
745 case MagickCore::ImageError:
746 case MagickCore::ImageFatalError:
747 return new ErrorImage(message);
748 case MagickCore::ImageWarning:
749 return new WarningImage(message);
750 case MagickCore::MissingDelegateError:
751 case MagickCore::MissingDelegateFatalError:
752 return new ErrorMissingDelegate(message);
753 case MagickCore::MissingDelegateWarning:
754 return new WarningMissingDelegate(message);
755 case MagickCore::ModuleError:
756 case MagickCore::ModuleFatalError:
757 return new ErrorModule(message);
758 case MagickCore::ModuleWarning:
759 return new WarningModule(message);
760 case MagickCore::MonitorError:
761 case MagickCore::MonitorFatalError:
762 return new ErrorMonitor(message);
763 case MagickCore::MonitorWarning:
764 return new WarningMonitor(message);
765 case MagickCore::OptionError:
766 case MagickCore::OptionFatalError:
767 return new ErrorOption(message);
768 case MagickCore::OptionWarning:
769 return new WarningOption(message);
770 case MagickCore::PolicyWarning:
771 return new WarningPolicy(message);
772 case MagickCore::PolicyError:
773 case MagickCore::PolicyFatalError:
774 return new ErrorPolicy(message);
775 case MagickCore::RegistryError:
776 case MagickCore::RegistryFatalError:
777 return new ErrorRegistry(message);
778 case MagickCore::RegistryWarning:
779 return new WarningRegistry(message);
780 case MagickCore::ResourceLimitError:
781 case MagickCore::ResourceLimitFatalError:
782 return new ErrorResourceLimit(message);
783 case MagickCore::ResourceLimitWarning:
784 return new WarningResourceLimit(message);
785 case MagickCore::StreamError:
786 case MagickCore::StreamFatalError:
787 return new ErrorStream(message);
788 case MagickCore::StreamWarning:
789 return new WarningStream(message);
790 case MagickCore::TypeError:
791 case MagickCore::TypeFatalError:
792 return new ErrorType(message);
793 case MagickCore::TypeWarning:
794 return new WarningType(message);
795 case MagickCore::UndefinedException:
796 default:
797 return new ErrorUndefined(message);
798 case MagickCore::XServerError:
799 case MagickCore::XServerFatalError:
800 return new ErrorXServer(message);
801 case MagickCore::XServerWarning:
802 return new WarningXServer(message);
803 }
804 }
805
throwExceptionExplicit(const MagickCore::ExceptionType severity_,const char * reason_,const char * description_)806 MagickPPExport void Magick::throwExceptionExplicit(
807 const MagickCore::ExceptionType severity_,const char* reason_,
808 const char* description_)
809 {
810 // Just return if there is no reported error
811 if (severity_ == MagickCore::UndefinedException)
812 return;
813
814 GetPPException;
815 ThrowException(exceptionInfo,severity_,reason_,description_);
816 ThrowPPException(false);
817 }
818
throwException(ExceptionInfo * exception_,const bool quiet_)819 MagickPPExport void Magick::throwException(ExceptionInfo *exception_,
820 const bool quiet_)
821 {
822 const ExceptionInfo
823 *p;
824
825 Exception
826 *nestedException,
827 *q;
828
829 MagickCore::ExceptionType
830 severity;
831
832 size_t
833 index;
834
835 std::string
836 message;
837
838 // Just return if there is no reported error
839 if (exception_->severity == MagickCore::UndefinedException)
840 return;
841
842 message=formatExceptionMessage(exception_);
843 nestedException=(Exception *) NULL;
844 q=(Exception *) NULL;
845 LockSemaphoreInfo(exception_->semaphore);
846 if (exception_->exceptions != (void *) NULL)
847 {
848 index=GetNumberOfElementsInLinkedList((LinkedListInfo *)
849 exception_->exceptions);
850 while(index > 0)
851 {
852 p=(const ExceptionInfo *) GetValueFromLinkedList((LinkedListInfo *)
853 exception_->exceptions,--index);
854 if ((p->severity != exception_->severity) || (LocaleCompare(p->reason,
855 exception_->reason) != 0) || (LocaleCompare(p->description,
856 exception_->description) != 0))
857 {
858 if (nestedException == (Exception *) NULL)
859 {
860 nestedException=createException(p);
861 q=nestedException;
862 }
863 else
864 {
865 Exception
866 *r;
867
868 r=createException(p);
869 q->nested(r);
870 q=r;
871 }
872 }
873 }
874 }
875 severity=exception_->severity;
876 UnlockSemaphoreInfo(exception_->semaphore);
877
878 if ((quiet_) && (severity < MagickCore::ErrorException))
879 {
880 delete nestedException;
881 return;
882 }
883
884 DestroyExceptionInfo(exception_);
885
886 switch (severity)
887 {
888 case MagickCore::BlobError:
889 case MagickCore::BlobFatalError:
890 throw ErrorBlob(message,nestedException);
891 case MagickCore::BlobWarning:
892 throw WarningBlob(message,nestedException);
893 case MagickCore::CacheError:
894 case MagickCore::CacheFatalError:
895 throw ErrorCache(message,nestedException);
896 case MagickCore::CacheWarning:
897 throw WarningCache(message,nestedException);
898 case MagickCore::CoderError:
899 case MagickCore::CoderFatalError:
900 throw ErrorCoder(message,nestedException);
901 case MagickCore::CoderWarning:
902 throw WarningCoder(message,nestedException);
903 case MagickCore::ConfigureError:
904 case MagickCore::ConfigureFatalError:
905 throw ErrorConfigure(message,nestedException);
906 case MagickCore::ConfigureWarning:
907 throw WarningConfigure(message,nestedException);
908 case MagickCore::CorruptImageError:
909 case MagickCore::CorruptImageFatalError:
910 throw ErrorCorruptImage(message,nestedException);
911 case MagickCore::CorruptImageWarning:
912 throw WarningCorruptImage(message,nestedException);
913 case MagickCore::DelegateError:
914 case MagickCore::DelegateFatalError:
915 throw ErrorDelegate(message,nestedException);
916 case MagickCore::DelegateWarning:
917 throw WarningDelegate(message,nestedException);
918 case MagickCore::DrawError:
919 case MagickCore::DrawFatalError:
920 throw ErrorDraw(message,nestedException);
921 case MagickCore::DrawWarning:
922 throw WarningDraw(message,nestedException);
923 case MagickCore::FileOpenError:
924 case MagickCore::FileOpenFatalError:
925 throw ErrorFileOpen(message,nestedException);
926 case MagickCore::FileOpenWarning:
927 throw WarningFileOpen(message,nestedException);
928 case MagickCore::ImageError:
929 case MagickCore::ImageFatalError:
930 throw ErrorImage(message,nestedException);
931 case MagickCore::ImageWarning:
932 throw WarningImage(message,nestedException);
933 case MagickCore::MissingDelegateError:
934 case MagickCore::MissingDelegateFatalError:
935 throw ErrorMissingDelegate(message,nestedException);
936 case MagickCore::MissingDelegateWarning:
937 throw WarningMissingDelegate(message,nestedException);
938 case MagickCore::ModuleError:
939 case MagickCore::ModuleFatalError:
940 throw ErrorModule(message,nestedException);
941 case MagickCore::ModuleWarning:
942 throw WarningModule(message,nestedException);
943 case MagickCore::MonitorError:
944 case MagickCore::MonitorFatalError:
945 throw ErrorMonitor(message,nestedException);
946 case MagickCore::MonitorWarning:
947 throw WarningMonitor(message,nestedException);
948 case MagickCore::OptionError:
949 case MagickCore::OptionFatalError:
950 throw ErrorOption(message,nestedException);
951 case MagickCore::OptionWarning:
952 throw WarningOption(message,nestedException);
953 case MagickCore::PolicyWarning:
954 throw WarningPolicy(message,nestedException);
955 case MagickCore::PolicyError:
956 case MagickCore::PolicyFatalError:
957 throw ErrorPolicy(message,nestedException);
958 case MagickCore::RegistryError:
959 case MagickCore::RegistryFatalError:
960 throw ErrorRegistry(message,nestedException);
961 case MagickCore::RegistryWarning:
962 throw WarningRegistry(message,nestedException);
963 case MagickCore::ResourceLimitError:
964 case MagickCore::ResourceLimitFatalError:
965 throw ErrorResourceLimit(message,nestedException);
966 case MagickCore::ResourceLimitWarning:
967 throw WarningResourceLimit(message,nestedException);
968 case MagickCore::StreamError:
969 case MagickCore::StreamFatalError:
970 throw ErrorStream(message,nestedException);
971 case MagickCore::StreamWarning:
972 throw WarningStream(message,nestedException);
973 case MagickCore::TypeError:
974 case MagickCore::TypeFatalError:
975 throw ErrorType(message,nestedException);
976 case MagickCore::TypeWarning:
977 throw WarningType(message,nestedException);
978 case MagickCore::UndefinedException:
979 default:
980 throw ErrorUndefined(message,nestedException);
981 case MagickCore::XServerError:
982 case MagickCore::XServerFatalError:
983 throw ErrorXServer(message,nestedException);
984 case MagickCore::XServerWarning:
985 throw WarningXServer(message,nestedException);
986 }
987 }
988