11#define MAGICKCORE_IMPLEMENTATION 1
12#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
14#include "Magick++/Include.h"
18#include "Magick++/Exception.h"
20Magick::Exception::Exception(
const std::string& what_)
23 _nested((Exception *) NULL)
27Magick::Exception::Exception(
const std::string& what_,
36 : exception(original_),
37 _what(original_._what),
38 _nested((Exception *) NULL)
42Magick::Exception::~Exception() throw()
47Magick::Exception& Magick::Exception::operator=(
48 const Magick::Exception& original_)
50 if (
this != &original_)
51 this->_what=original_._what;
55const char* Magick::Exception::what()
const throw()
57 return(_what.c_str());
60const Magick::Exception* Magick::Exception::nested()
const throw()
65void Magick::Exception::nested(
Exception* nested_)
throw()
70Magick::Error::Error(
const std::string& what_)
75Magick::Error::Error(
const std::string& what_,Exception *nested_)
76 : Exception(what_,nested_)
80Magick::Error::~Error() throw()
84Magick::ErrorBlob::ErrorBlob(
const std::string& what_)
89Magick::ErrorBlob::ErrorBlob(
const std::string& what_,Exception *nested_)
90 : Error(what_,nested_)
94Magick::ErrorBlob::~ErrorBlob() throw()
98Magick::ErrorCache::ErrorCache(
const std::string& what_)
103Magick::ErrorCache::ErrorCache(
const std::string& what_,Exception *nested_)
104 : Error(what_,nested_)
108Magick::ErrorCache::~ErrorCache() throw()
112Magick::ErrorCoder::ErrorCoder(
const std::string& what_)
117Magick::ErrorCoder::ErrorCoder(
const std::string& what_,Exception *nested_)
118 : Error(what_,nested_)
122Magick::ErrorCoder::~ErrorCoder() throw()
126Magick::ErrorConfigure::ErrorConfigure(
const std::string& what_)
131Magick::ErrorConfigure::ErrorConfigure(
const std::string& what_,
133 : Error(what_,nested_)
137Magick::ErrorConfigure::~ErrorConfigure() throw()
141Magick::ErrorCorruptImage::ErrorCorruptImage(
const std::string& what_)
146Magick::ErrorCorruptImage::ErrorCorruptImage(
const std::string& what_,
148 : Error(what_,nested_)
152Magick::ErrorCorruptImage::~ErrorCorruptImage() throw()
156Magick::ErrorDelegate::ErrorDelegate(
const std::string& what_)
161Magick::ErrorDelegate::ErrorDelegate(
const std::string& what_,
163 : Error(what_,nested_)
167Magick::ErrorDelegate::~ErrorDelegate()throw()
171Magick::ErrorDraw::ErrorDraw(
const std::string& what_)
176Magick::ErrorDraw::ErrorDraw(
const std::string& what_,Exception *nested_)
177 : Error(what_,nested_)
181Magick::ErrorDraw::~ErrorDraw() throw()
185Magick::ErrorFileOpen::ErrorFileOpen(
const std::string& what_)
190Magick::ErrorFileOpen::~ErrorFileOpen() throw()
194Magick::ErrorFileOpen::ErrorFileOpen(
const std::string& what_,
196 :
Error(what_,nested_)
201Magick::ErrorImage::ErrorImage(
const std::string& what_)
206Magick::ErrorImage::ErrorImage(
const std::string& what_,Exception *nested_)
207 : Error(what_,nested_)
211Magick::ErrorImage::~ErrorImage() throw()
215Magick::ErrorMissingDelegate::ErrorMissingDelegate(
const std::string& what_)
220Magick::ErrorMissingDelegate::ErrorMissingDelegate(
const std::string& what_,
222 : Error(what_,nested_)
226Magick::ErrorMissingDelegate::~ErrorMissingDelegate() throw ()
230Magick::ErrorModule::ErrorModule(
const std::string& what_)
235Magick::ErrorModule::ErrorModule(
const std::string& what_,Exception *nested_)
236 : Error(what_,nested_)
240Magick::ErrorModule::~ErrorModule() throw()
244Magick::ErrorMonitor::ErrorMonitor(
const std::string& what_)
249Magick::ErrorMonitor::ErrorMonitor(
const std::string& what_,Exception *nested_)
250 : Error(what_,nested_)
254Magick::ErrorMonitor::~ErrorMonitor() throw()
258Magick::ErrorOption::ErrorOption(
const std::string& what_)
263Magick::ErrorOption::ErrorOption(
const std::string& what_,Exception *nested_)
264 : Error(what_,nested_)
268Magick::ErrorOption::~ErrorOption() throw()
272Magick::ErrorPolicy::ErrorPolicy(
const std::string& what_)
277Magick::ErrorPolicy::ErrorPolicy(
const std::string& what_,Exception *nested_)
278 : Error(what_,nested_)
282Magick::ErrorPolicy::~ErrorPolicy() throw()
287Magick::ErrorRegistry::ErrorRegistry(
const std::string& what_)
292Magick::ErrorRegistry::ErrorRegistry(
const std::string& what_,
294 : Error(what_,nested_)
298Magick::ErrorRegistry::~ErrorRegistry() throw()
302Magick::ErrorResourceLimit::ErrorResourceLimit(
const std::string& what_)
307Magick::ErrorResourceLimit::ErrorResourceLimit(
const std::string& what_,
309 : Error(what_,nested_)
313Magick::ErrorResourceLimit::~ErrorResourceLimit() throw()
317Magick::ErrorStream::ErrorStream(
const std::string& what_)
322Magick::ErrorStream::ErrorStream(
const std::string& what_,Exception *nested_)
323 : Error(what_,nested_)
327Magick::ErrorStream::~ErrorStream() throw()
331Magick::ErrorType::ErrorType(
const std::string& what_)
336Magick::ErrorType::ErrorType(
const std::string& what_,Exception *nested_)
337 : Error(what_,nested_)
341Magick::ErrorType::~ErrorType() throw()
345Magick::ErrorUndefined::ErrorUndefined(
const std::string& what_)
350Magick::ErrorUndefined::ErrorUndefined(
const std::string& what_,
352 : Error(what_,nested_)
356Magick::ErrorUndefined::~ErrorUndefined() throw()
360Magick::ErrorXServer::ErrorXServer(
const std::string& what_)
365Magick::ErrorXServer::ErrorXServer(
const std::string& what_,Exception *nested_)
366 : Error(what_,nested_)
370Magick::ErrorXServer::~ErrorXServer() throw ()
374Magick::Warning::Warning(
const std::string& what_)
379Magick::Warning::Warning(
const std::string& what_,Exception *nested_)
380 : Exception(what_,nested_)
384Magick::Warning::~Warning() throw()
388Magick::WarningBlob::WarningBlob(
const std::string& what_)
393Magick::WarningBlob::WarningBlob(
const std::string& what_,Exception *nested_)
394 : Warning(what_,nested_)
398Magick::WarningBlob::~WarningBlob() throw()
402Magick::WarningCache::WarningCache(
const std::string& what_)
407Magick::WarningCache::WarningCache(
const std::string& what_,Exception *nested_)
408 : Warning(what_,nested_)
412Magick::WarningCache::~WarningCache() throw()
416Magick::WarningCoder::WarningCoder(
const std::string& what_)
421Magick::WarningCoder::WarningCoder(
const std::string& what_,Exception *nested_)
422 : Warning(what_,nested_)
426Magick::WarningCoder::~WarningCoder() throw()
430Magick::WarningConfigure::WarningConfigure(
const std::string& what_)
435Magick::WarningConfigure::WarningConfigure(
const std::string& what_,
437 : Warning(what_,nested_)
441Magick::WarningConfigure::~WarningConfigure() throw()
445Magick::WarningCorruptImage::WarningCorruptImage(
const std::string& what_)
450Magick::WarningCorruptImage::WarningCorruptImage(
const std::string& what_,
452 : Warning(what_,nested_)
456Magick::WarningCorruptImage::~WarningCorruptImage() throw()
460Magick::WarningDelegate::WarningDelegate(
const std::string& what_)
465Magick::WarningDelegate::WarningDelegate(
const std::string& what_,
467 : Warning(what_,nested_)
471Magick::WarningDelegate::~WarningDelegate() throw()
475Magick::WarningDraw::WarningDraw(
const std::string& what_)
480Magick::WarningDraw::WarningDraw(
const std::string& what_,Exception *nested_)
481 : Warning(what_,nested_)
485Magick::WarningDraw::~WarningDraw() throw()
489Magick::WarningFileOpen::WarningFileOpen(
const std::string& what_)
494Magick::WarningFileOpen::WarningFileOpen(
const std::string& what_,
496 : Warning(what_,nested_)
500Magick::WarningFileOpen::~WarningFileOpen() throw()
504Magick::WarningImage::WarningImage(
const std::string& what_)
509Magick::WarningImage::WarningImage(
const std::string& what_,Exception *nested_)
510 : Warning(what_,nested_)
514Magick::WarningImage::~WarningImage() throw()
518Magick::WarningMissingDelegate::WarningMissingDelegate(
519 const std::string& what_)
524Magick::WarningMissingDelegate::WarningMissingDelegate(
525 const std::string& what_,Exception *nested_)
526 : Warning(what_,nested_)
530Magick::WarningMissingDelegate::~WarningMissingDelegate() throw()
534Magick::WarningModule::WarningModule(
const std::string& what_)
539Magick::WarningModule::WarningModule(
const std::string& what_,
541 : Warning(what_,nested_)
546Magick::WarningModule::~WarningModule() throw()
550Magick::WarningMonitor::WarningMonitor(
const std::string& what_)
555Magick::WarningMonitor::WarningMonitor(
const std::string& what_,
557 : Warning(what_,nested_)
561Magick::WarningMonitor::~WarningMonitor() throw()
565Magick::WarningOption::WarningOption(
const std::string& what_)
570Magick::WarningOption::WarningOption(
const std::string& what_,
572 : Warning(what_,nested_)
576Magick::WarningOption::~WarningOption() throw()
580Magick::WarningRegistry::WarningRegistry(
const std::string& what_)
585Magick::WarningRegistry::WarningRegistry(
const std::string& what_,
587 : Warning(what_,nested_)
591Magick::WarningRegistry::~WarningRegistry() throw()
595Magick::WarningPolicy::WarningPolicy(
const std::string& what_)
600Magick::WarningPolicy::WarningPolicy(
const std::string& what_,
602 : Warning(what_,nested_)
606Magick::WarningPolicy::~WarningPolicy() throw()
610Magick::WarningResourceLimit::WarningResourceLimit(
const std::string& what_)
615Magick::WarningResourceLimit::WarningResourceLimit(
const std::string& what_,
617 : Warning(what_,nested_)
621Magick::WarningResourceLimit::~WarningResourceLimit() throw()
625Magick::WarningStream::WarningStream(
const std::string& what_)
630Magick::WarningStream::WarningStream(
const std::string& what_,
632 : Warning(what_,nested_)
636Magick::WarningStream::~WarningStream() throw()
640Magick::WarningType::WarningType(
const std::string& what_)
645Magick::WarningType::WarningType(
const std::string& what_,Exception *nested_)
646 : Warning(what_,nested_)
650Magick::WarningType::~WarningType() throw()
654Magick::WarningUndefined::WarningUndefined(
const std::string& what_)
659Magick::WarningUndefined::WarningUndefined(
const std::string& what_,
661 : Warning(what_,nested_)
665Magick::WarningUndefined::~WarningUndefined() throw()
669Magick::WarningXServer::WarningXServer(
const std::string& what_)
674Magick::WarningXServer::WarningXServer(
const std::string& what_,
676 : Warning(what_,nested_)
680Magick::WarningXServer::~WarningXServer() throw()
684std::string Magick::formatExceptionMessage(
const MagickCore::ExceptionInfo *exception_)
687 std::string message=GetClientName();
688 if (exception_->reason != (
char *) NULL)
690 message+=std::string(
": ");
691 message+=std::string(exception_->reason);
694 if (exception_->description != (
char *) NULL)
695 message +=
" (" + std::string(exception_->description) +
")";
699Magick::Exception* Magick::createException(
const MagickCore::ExceptionInfo *exception_)
701 std::string message=formatExceptionMessage(exception_);
702 switch (exception_->severity)
704 case MagickCore::BlobError:
705 case MagickCore::BlobFatalError:
707 case MagickCore::BlobWarning:
709 case MagickCore::CacheError:
710 case MagickCore::CacheFatalError:
712 case MagickCore::CacheWarning:
714 case MagickCore::CoderError:
715 case MagickCore::CoderFatalError:
717 case MagickCore::CoderWarning:
719 case MagickCore::ConfigureError:
720 case MagickCore::ConfigureFatalError:
722 case MagickCore::ConfigureWarning:
724 case MagickCore::CorruptImageError:
725 case MagickCore::CorruptImageFatalError:
727 case MagickCore::CorruptImageWarning:
729 case MagickCore::DelegateError:
730 case MagickCore::DelegateFatalError:
732 case MagickCore::DelegateWarning:
734 case MagickCore::DrawError:
735 case MagickCore::DrawFatalError:
737 case MagickCore::DrawWarning:
739 case MagickCore::FileOpenError:
740 case MagickCore::FileOpenFatalError:
742 case MagickCore::FileOpenWarning:
744 case MagickCore::ImageError:
745 case MagickCore::ImageFatalError:
747 case MagickCore::ImageWarning:
749 case MagickCore::MissingDelegateError:
750 case MagickCore::MissingDelegateFatalError:
752 case MagickCore::MissingDelegateWarning:
754 case MagickCore::ModuleError:
755 case MagickCore::ModuleFatalError:
757 case MagickCore::ModuleWarning:
759 case MagickCore::MonitorError:
760 case MagickCore::MonitorFatalError:
762 case MagickCore::MonitorWarning:
764 case MagickCore::OptionError:
765 case MagickCore::OptionFatalError:
767 case MagickCore::OptionWarning:
769 case MagickCore::PolicyWarning:
771 case MagickCore::PolicyError:
772 case MagickCore::PolicyFatalError:
774 case MagickCore::RegistryError:
775 case MagickCore::RegistryFatalError:
777 case MagickCore::RegistryWarning:
779 case MagickCore::ResourceLimitError:
780 case MagickCore::ResourceLimitFatalError:
782 case MagickCore::ResourceLimitWarning:
784 case MagickCore::StreamError:
785 case MagickCore::StreamFatalError:
787 case MagickCore::StreamWarning:
789 case MagickCore::TypeError:
790 case MagickCore::TypeFatalError:
792 case MagickCore::TypeWarning:
794 case MagickCore::UndefinedException:
797 case MagickCore::XServerError:
798 case MagickCore::XServerFatalError:
800 case MagickCore::XServerWarning:
805MagickPPExport
void Magick::throwExceptionExplicit(
806 const MagickCore::ExceptionType severity_,
const char* reason_,
807 const char* description_)
810 if (severity_ == MagickCore::UndefinedException)
814 ThrowException(exceptionInfo,severity_,reason_,description_);
815 ThrowPPException(
false);
818MagickPPExport
void Magick::throwException(ExceptionInfo *exception_,
828 MagickCore::ExceptionType
838 if (exception_->severity == MagickCore::UndefinedException)
841 message=formatExceptionMessage(exception_);
844 LockSemaphoreInfo(exception_->semaphore);
845 if (exception_->exceptions != (
void *) NULL)
847 index=GetNumberOfElementsInLinkedList((LinkedListInfo *)
848 exception_->exceptions);
851 p=(
const ExceptionInfo *) GetValueFromLinkedList((LinkedListInfo *)
852 exception_->exceptions,--index);
853 if ((p->severity != exception_->severity) || (LocaleCompare(p->reason,
854 exception_->reason) != 0) || (LocaleCompare(p->description,
855 exception_->description) != 0))
857 if (nestedException == (
Exception *) NULL)
859 nestedException=createException(p);
867 r=createException(p);
874 severity=exception_->severity;
875 UnlockSemaphoreInfo(exception_->semaphore);
877 if ((quiet_) && (severity < MagickCore::ErrorException))
879 delete nestedException;
883 DestroyExceptionInfo(exception_);
887 case MagickCore::BlobError:
888 case MagickCore::BlobFatalError:
889 throw ErrorBlob(message,nestedException);
890 case MagickCore::BlobWarning:
892 case MagickCore::CacheError:
893 case MagickCore::CacheFatalError:
895 case MagickCore::CacheWarning:
897 case MagickCore::CoderError:
898 case MagickCore::CoderFatalError:
900 case MagickCore::CoderWarning:
902 case MagickCore::ConfigureError:
903 case MagickCore::ConfigureFatalError:
905 case MagickCore::ConfigureWarning:
907 case MagickCore::CorruptImageError:
908 case MagickCore::CorruptImageFatalError:
910 case MagickCore::CorruptImageWarning:
912 case MagickCore::DelegateError:
913 case MagickCore::DelegateFatalError:
915 case MagickCore::DelegateWarning:
917 case MagickCore::DrawError:
918 case MagickCore::DrawFatalError:
919 throw ErrorDraw(message,nestedException);
920 case MagickCore::DrawWarning:
922 case MagickCore::FileOpenError:
923 case MagickCore::FileOpenFatalError:
925 case MagickCore::FileOpenWarning:
927 case MagickCore::ImageError:
928 case MagickCore::ImageFatalError:
930 case MagickCore::ImageWarning:
932 case MagickCore::MissingDelegateError:
933 case MagickCore::MissingDelegateFatalError:
935 case MagickCore::MissingDelegateWarning:
937 case MagickCore::ModuleError:
938 case MagickCore::ModuleFatalError:
940 case MagickCore::ModuleWarning:
942 case MagickCore::MonitorError:
943 case MagickCore::MonitorFatalError:
945 case MagickCore::MonitorWarning:
947 case MagickCore::OptionError:
948 case MagickCore::OptionFatalError:
950 case MagickCore::OptionWarning:
952 case MagickCore::PolicyWarning:
954 case MagickCore::PolicyError:
955 case MagickCore::PolicyFatalError:
957 case MagickCore::RegistryError:
958 case MagickCore::RegistryFatalError:
960 case MagickCore::RegistryWarning:
962 case MagickCore::ResourceLimitError:
963 case MagickCore::ResourceLimitFatalError:
965 case MagickCore::ResourceLimitWarning:
967 case MagickCore::StreamError:
968 case MagickCore::StreamFatalError:
970 case MagickCore::StreamWarning:
972 case MagickCore::TypeError:
973 case MagickCore::TypeFatalError:
974 throw ErrorType(message,nestedException);
975 case MagickCore::TypeWarning:
977 case MagickCore::UndefinedException:
980 case MagickCore::XServerError:
981 case MagickCore::XServerFatalError:
983 case MagickCore::XServerWarning: