9#define MAGICKCORE_IMPLEMENTATION 1
10#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
12#include "Magick++/Include.h"
17#include "Magick++/Exception.h"
21Magick::Exception::Exception(
const std::string& what_)
24 _nested((Exception *) NULL)
28Magick::Exception::Exception(
const std::string& what_,
37 : exception(original_),
38 _what(original_._what),
39 _nested((Exception *) NULL)
43Magick::Exception::~Exception() throw()
45 if (_nested != (Exception *) NULL)
49Magick::Exception& Magick::Exception::operator=(
50 const Magick::Exception& original_)
52 if (
this != &original_)
53 this->_what=original_._what;
57const char* Magick::Exception::what()
const throw()
59 return(_what.c_str());
62const Magick::Exception* Magick::Exception::nested()
const throw()
67void Magick::Exception::nested(
Exception* nested_)
throw()
72Magick::Error::Error(
const std::string& what_)
77Magick::Error::Error(
const std::string& what_,Exception *nested_)
78 : Exception(what_,nested_)
82Magick::Error::~Error() throw()
86Magick::ErrorBlob::ErrorBlob(
const std::string& what_)
91Magick::ErrorBlob::ErrorBlob(
const std::string& what_,Exception *nested_)
92 : Error(what_,nested_)
96Magick::ErrorBlob::~ErrorBlob() throw()
100Magick::ErrorCache::ErrorCache(
const std::string& what_)
105Magick::ErrorCache::ErrorCache(
const std::string& what_,Exception *nested_)
106 : Error(what_,nested_)
110Magick::ErrorCache::~ErrorCache() throw()
114Magick::ErrorCoder::ErrorCoder(
const std::string& what_)
119Magick::ErrorCoder::ErrorCoder(
const std::string& what_,Exception *nested_)
120 : Error(what_,nested_)
124Magick::ErrorCoder::~ErrorCoder() throw()
128Magick::ErrorConfigure::ErrorConfigure(
const std::string& what_)
133Magick::ErrorConfigure::ErrorConfigure(
const std::string& what_,
135 : Error(what_,nested_)
139Magick::ErrorConfigure::~ErrorConfigure() throw()
143Magick::ErrorCorruptImage::ErrorCorruptImage(
const std::string& what_)
148Magick::ErrorCorruptImage::ErrorCorruptImage(
const std::string& what_,
150 : Error(what_,nested_)
154Magick::ErrorCorruptImage::~ErrorCorruptImage() throw()
158Magick::ErrorDelegate::ErrorDelegate(
const std::string& what_)
163Magick::ErrorDelegate::ErrorDelegate(
const std::string& what_,
165 : Error(what_,nested_)
169Magick::ErrorDelegate::~ErrorDelegate()throw()
173Magick::ErrorDraw::ErrorDraw(
const std::string& what_)
178Magick::ErrorDraw::ErrorDraw(
const std::string& what_,Exception *nested_)
179 : Error(what_,nested_)
183Magick::ErrorDraw::~ErrorDraw() throw()
187Magick::ErrorFileOpen::ErrorFileOpen(
const std::string& what_)
192Magick::ErrorFileOpen::~ErrorFileOpen() throw()
196Magick::ErrorFileOpen::ErrorFileOpen(
const std::string& what_,
198 :
Error(what_,nested_)
203Magick::ErrorImage::ErrorImage(
const std::string& what_)
208Magick::ErrorImage::ErrorImage(
const std::string& what_,Exception *nested_)
209 : Error(what_,nested_)
213Magick::ErrorImage::~ErrorImage() throw()
217Magick::ErrorMissingDelegate::ErrorMissingDelegate(
const std::string& what_)
222Magick::ErrorMissingDelegate::ErrorMissingDelegate(
const std::string& what_,
224 : Error(what_,nested_)
228Magick::ErrorMissingDelegate::~ErrorMissingDelegate() throw ()
232Magick::ErrorModule::ErrorModule(
const std::string& what_)
237Magick::ErrorModule::ErrorModule(
const std::string& what_,Exception *nested_)
238 : Error(what_,nested_)
242Magick::ErrorModule::~ErrorModule() throw()
246Magick::ErrorMonitor::ErrorMonitor(
const std::string& what_)
251Magick::ErrorMonitor::ErrorMonitor(
const std::string& what_,Exception *nested_)
252 : Error(what_,nested_)
256Magick::ErrorMonitor::~ErrorMonitor() throw()
260Magick::ErrorOption::ErrorOption(
const std::string& what_)
265Magick::ErrorOption::ErrorOption(
const std::string& what_,Exception *nested_)
266 : Error(what_,nested_)
270Magick::ErrorOption::~ErrorOption() throw()
274Magick::ErrorPolicy::ErrorPolicy(
const std::string& what_)
279Magick::ErrorPolicy::ErrorPolicy(
const std::string& what_,Exception *nested_)
280 : Error(what_,nested_)
284Magick::ErrorPolicy::~ErrorPolicy() throw()
289Magick::ErrorRegistry::ErrorRegistry(
const std::string& what_)
294Magick::ErrorRegistry::ErrorRegistry(
const std::string& what_,
296 : Error(what_,nested_)
300Magick::ErrorRegistry::~ErrorRegistry() throw()
304Magick::ErrorResourceLimit::ErrorResourceLimit(
const std::string& what_)
309Magick::ErrorResourceLimit::ErrorResourceLimit(
const std::string& what_,
311 : Error(what_,nested_)
315Magick::ErrorResourceLimit::~ErrorResourceLimit() throw()
319Magick::ErrorStream::ErrorStream(
const std::string& what_)
324Magick::ErrorStream::ErrorStream(
const std::string& what_,Exception *nested_)
325 : Error(what_,nested_)
329Magick::ErrorStream::~ErrorStream() throw()
333Magick::ErrorType::ErrorType(
const std::string& what_)
338Magick::ErrorType::ErrorType(
const std::string& what_,Exception *nested_)
339 : Error(what_,nested_)
343Magick::ErrorType::~ErrorType() throw()
347Magick::ErrorUndefined::ErrorUndefined(
const std::string& what_)
352Magick::ErrorUndefined::ErrorUndefined(
const std::string& what_,
354 : Error(what_,nested_)
358Magick::ErrorUndefined::~ErrorUndefined() throw()
362Magick::ErrorXServer::ErrorXServer(
const std::string& what_)
367Magick::ErrorXServer::ErrorXServer(
const std::string& what_,Exception *nested_)
368 : Error(what_,nested_)
372Magick::ErrorXServer::~ErrorXServer() throw ()
376Magick::Warning::Warning(
const std::string& what_)
381Magick::Warning::Warning(
const std::string& what_,Exception *nested_)
382 : Exception(what_,nested_)
386Magick::Warning::~Warning() throw()
390Magick::WarningBlob::WarningBlob(
const std::string& what_)
395Magick::WarningBlob::WarningBlob(
const std::string& what_,Exception *nested_)
396 : Warning(what_,nested_)
400Magick::WarningBlob::~WarningBlob() throw()
404Magick::WarningCache::WarningCache(
const std::string& what_)
409Magick::WarningCache::WarningCache(
const std::string& what_,Exception *nested_)
410 : Warning(what_,nested_)
414Magick::WarningCache::~WarningCache() throw()
418Magick::WarningCoder::WarningCoder(
const std::string& what_)
423Magick::WarningCoder::WarningCoder(
const std::string& what_,Exception *nested_)
424 : Warning(what_,nested_)
428Magick::WarningCoder::~WarningCoder() throw()
432Magick::WarningConfigure::WarningConfigure(
const std::string& what_)
437Magick::WarningConfigure::WarningConfigure(
const std::string& what_,
439 : Warning(what_,nested_)
443Magick::WarningConfigure::~WarningConfigure() throw()
447Magick::WarningCorruptImage::WarningCorruptImage(
const std::string& what_)
452Magick::WarningCorruptImage::WarningCorruptImage(
const std::string& what_,
454 : Warning(what_,nested_)
458Magick::WarningCorruptImage::~WarningCorruptImage() throw()
462Magick::WarningDelegate::WarningDelegate(
const std::string& what_)
467Magick::WarningDelegate::WarningDelegate(
const std::string& what_,
469 : Warning(what_,nested_)
473Magick::WarningDelegate::~WarningDelegate() throw()
477Magick::WarningDraw::WarningDraw(
const std::string& what_)
482Magick::WarningDraw::WarningDraw(
const std::string& what_,Exception *nested_)
483 : Warning(what_,nested_)
487Magick::WarningDraw::~WarningDraw() throw()
491Magick::WarningFileOpen::WarningFileOpen(
const std::string& what_)
496Magick::WarningFileOpen::WarningFileOpen(
const std::string& what_,
498 : Warning(what_,nested_)
502Magick::WarningFileOpen::~WarningFileOpen() throw()
506Magick::WarningImage::WarningImage(
const std::string& what_)
511Magick::WarningImage::WarningImage(
const std::string& what_,Exception *nested_)
512 : Warning(what_,nested_)
516Magick::WarningImage::~WarningImage() throw()
520Magick::WarningMissingDelegate::WarningMissingDelegate(
521 const std::string& what_)
526Magick::WarningMissingDelegate::WarningMissingDelegate(
527 const std::string& what_,Exception *nested_)
528 : Warning(what_,nested_)
532Magick::WarningMissingDelegate::~WarningMissingDelegate() throw()
536Magick::WarningModule::WarningModule(
const std::string& what_)
541Magick::WarningModule::WarningModule(
const std::string& what_,
543 : Warning(what_,nested_)
548Magick::WarningModule::~WarningModule() throw()
552Magick::WarningMonitor::WarningMonitor(
const std::string& what_)
557Magick::WarningMonitor::WarningMonitor(
const std::string& what_,
559 : Warning(what_,nested_)
563Magick::WarningMonitor::~WarningMonitor() throw()
567Magick::WarningOption::WarningOption(
const std::string& what_)
572Magick::WarningOption::WarningOption(
const std::string& what_,
574 : Warning(what_,nested_)
578Magick::WarningOption::~WarningOption() throw()
582Magick::WarningRegistry::WarningRegistry(
const std::string& what_)
587Magick::WarningRegistry::WarningRegistry(
const std::string& what_,
589 : Warning(what_,nested_)
593Magick::WarningRegistry::~WarningRegistry() throw()
597Magick::WarningPolicy::WarningPolicy(
const std::string& what_)
602Magick::WarningPolicy::WarningPolicy(
const std::string& what_,
604 : Warning(what_,nested_)
608Magick::WarningPolicy::~WarningPolicy() throw()
612Magick::WarningResourceLimit::WarningResourceLimit(
const std::string& what_)
617Magick::WarningResourceLimit::WarningResourceLimit(
const std::string& what_,
619 : Warning(what_,nested_)
623Magick::WarningResourceLimit::~WarningResourceLimit() throw()
627Magick::WarningStream::WarningStream(
const std::string& what_)
632Magick::WarningStream::WarningStream(
const std::string& what_,
634 : Warning(what_,nested_)
638Magick::WarningStream::~WarningStream() throw()
642Magick::WarningType::WarningType(
const std::string& what_)
647Magick::WarningType::WarningType(
const std::string& what_,Exception *nested_)
648 : Warning(what_,nested_)
652Magick::WarningType::~WarningType() throw()
656Magick::WarningUndefined::WarningUndefined(
const std::string& what_)
661Magick::WarningUndefined::WarningUndefined(
const std::string& what_,
663 : Warning(what_,nested_)
667Magick::WarningUndefined::~WarningUndefined() throw()
671Magick::WarningXServer::WarningXServer(
const std::string& what_)
676Magick::WarningXServer::WarningXServer(
const std::string& what_,
678 : Warning(what_,nested_)
682Magick::WarningXServer::~WarningXServer() throw()
686std::string Magick::formatExceptionMessage(
const MagickCore::ExceptionInfo *exception_)
689 std::string message=GetClientName();
690 if (exception_->reason != (
char *) NULL)
692 message+=std::string(
": ");
693 message+=std::string(exception_->reason);
696 if (exception_->description != (
char *) NULL)
697 message +=
" (" + std::string(exception_->description) +
")";
701Magick::Exception* Magick::createException(
const MagickCore::ExceptionInfo *exception_)
703 std::string message=formatExceptionMessage(exception_);
704 switch (exception_->severity)
712 case CacheFatalError:
717 case CoderFatalError:
722 case ConfigureFatalError:
724 case ConfigureWarning:
726 case CorruptImageError:
727 case CorruptImageFatalError:
729 case CorruptImageWarning:
732 case DelegateFatalError:
734 case DelegateWarning:
742 case FileOpenFatalError:
744 case FileOpenWarning:
747 case ImageFatalError:
751 case MissingDelegateError:
752 case MissingDelegateFatalError:
754 case MissingDelegateWarning:
757 case ModuleFatalError:
762 case MonitorFatalError:
767 case OptionFatalError:
774 case PolicyFatalError:
777 case RegistryFatalError:
779 case RegistryWarning:
781 case ResourceLimitError:
782 case ResourceLimitFatalError:
784 case ResourceLimitWarning:
787 case StreamFatalError:
796 case UndefinedException:
800 case XServerFatalError:
807MagickPPExport
void Magick::throwExceptionExplicit(
808 const ExceptionType severity_,
const char* reason_,
const char* description_)
811 if (severity_ == UndefinedException)
815 ThrowException(exceptionInfo,severity_,reason_, description_);
816 ThrowPPException(
false);
819MagickPPExport
void Magick::throwException(ExceptionInfo *exception_,
836 if (exception_->severity == UndefinedException)
839 std::string message=formatExceptionMessage(exception_);
842 LockSemaphoreInfo(exception_->semaphore);
843 if (exception_->exceptions != (
void *) NULL)
845 index=GetNumberOfElementsInLinkedList((LinkedListInfo *)
846 exception_->exceptions);
849 p=(
const ExceptionInfo *) GetValueFromLinkedList((LinkedListInfo *)
850 exception_->exceptions,--index);
851 if ((p->severity != exception_->severity) || (LocaleCompare(p->reason,
852 exception_->reason) != 0) || (LocaleCompare(p->description,
853 exception_->description) != 0))
855 if (nestedException == (
Exception *) NULL)
857 nestedException=createException(p);
865 r=createException(p);
872 severity=exception_->severity;
873 UnlockSemaphoreInfo(exception_->semaphore);
875 if ((quiet_) && (severity < MagickCore::ErrorException))
877 delete nestedException;
881 DestroyExceptionInfo(exception_);
887 throw ErrorBlob(message,nestedException);
891 case CacheFatalError:
896 case CoderFatalError:
901 case ConfigureFatalError:
903 case ConfigureWarning:
905 case CorruptImageError:
906 case CorruptImageFatalError:
908 case CorruptImageWarning:
911 case DelegateFatalError:
913 case DelegateWarning:
917 throw ErrorDraw(message,nestedException);
921 case FileOpenFatalError:
923 case FileOpenWarning:
926 case ImageFatalError:
930 case MissingDelegateError:
931 case MissingDelegateFatalError:
933 case MissingDelegateWarning:
936 case ModuleFatalError:
941 case MonitorFatalError:
946 case OptionFatalError:
953 case PolicyFatalError:
956 case RegistryFatalError:
958 case RegistryWarning:
960 case ResourceLimitError:
961 case ResourceLimitFatalError:
963 case ResourceLimitWarning:
966 case StreamFatalError:
972 throw ErrorType(message,nestedException);
975 case UndefinedException:
979 case XServerFatalError: