11#define MAGICKCORE_IMPLEMENTATION 1
12#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
14#include "Magick++/Include.h"
21#include "Magick++/Exception.h"
23Magick::Exception::Exception(
const std::string& what_)
26 _nested((Exception *) NULL)
30Magick::Exception::Exception(
const std::string& what_,
39 : exception(original_),
40 _what(original_._what),
41 _nested((Exception *) NULL)
45Magick::Exception::~Exception() throw()
53 if (
this != &original_)
54 this->_what=original_._what;
58const char* Magick::Exception::what()
const throw()
60 return(_what.c_str());
68void Magick::Exception::nested(Exception* nested_)
throw()
73Magick::Error::Error(
const std::string& what_)
78Magick::Error::Error(
const std::string& what_,Exception *nested_)
79 : Exception(what_,nested_)
83Magick::Error::~Error() throw()
87Magick::ErrorBlob::ErrorBlob(
const std::string& what_)
92Magick::ErrorBlob::ErrorBlob(
const std::string& what_,Exception *nested_)
93 : Error(what_,nested_)
97Magick::ErrorBlob::~ErrorBlob() throw()
101Magick::ErrorCache::ErrorCache(
const std::string& what_)
106Magick::ErrorCache::ErrorCache(
const std::string& what_,Exception *nested_)
107 : Error(what_,nested_)
111Magick::ErrorCache::~ErrorCache() throw()
115Magick::ErrorCoder::ErrorCoder(
const std::string& what_)
120Magick::ErrorCoder::ErrorCoder(
const std::string& what_,Exception *nested_)
121 : Error(what_,nested_)
125Magick::ErrorCoder::~ErrorCoder() throw()
129Magick::ErrorConfigure::ErrorConfigure(
const std::string& what_)
134Magick::ErrorConfigure::ErrorConfigure(
const std::string& what_,
136 : Error(what_,nested_)
140Magick::ErrorConfigure::~ErrorConfigure() throw()
144Magick::ErrorCorruptImage::ErrorCorruptImage(
const std::string& what_)
149Magick::ErrorCorruptImage::ErrorCorruptImage(
const std::string& what_,
151 : Error(what_,nested_)
155Magick::ErrorCorruptImage::~ErrorCorruptImage() throw()
159Magick::ErrorDelegate::ErrorDelegate(
const std::string& what_)
164Magick::ErrorDelegate::ErrorDelegate(
const std::string& what_,
166 : Error(what_,nested_)
170Magick::ErrorDelegate::~ErrorDelegate()throw()
174Magick::ErrorDraw::ErrorDraw(
const std::string& what_)
179Magick::ErrorDraw::ErrorDraw(
const std::string& what_,Exception *nested_)
180 : Error(what_,nested_)
184Magick::ErrorDraw::~ErrorDraw() throw()
188Magick::ErrorFileOpen::ErrorFileOpen(
const std::string& what_)
193Magick::ErrorFileOpen::~ErrorFileOpen() throw()
197Magick::ErrorFileOpen::ErrorFileOpen(
const std::string& what_,
199 : Error(what_,nested_)
204Magick::ErrorImage::ErrorImage(
const std::string& what_)
209Magick::ErrorImage::ErrorImage(
const std::string& what_,Exception *nested_)
210 : Error(what_,nested_)
214Magick::ErrorImage::~ErrorImage() throw()
218Magick::ErrorMissingDelegate::ErrorMissingDelegate(
const std::string& what_)
223Magick::ErrorMissingDelegate::ErrorMissingDelegate(
const std::string& what_,
225 : Error(what_,nested_)
229Magick::ErrorMissingDelegate::~ErrorMissingDelegate() throw ()
233Magick::ErrorModule::ErrorModule(
const std::string& what_)
238Magick::ErrorModule::ErrorModule(
const std::string& what_,Exception *nested_)
239 : Error(what_,nested_)
243Magick::ErrorModule::~ErrorModule() throw()
247Magick::ErrorMonitor::ErrorMonitor(
const std::string& what_)
252Magick::ErrorMonitor::ErrorMonitor(
const std::string& what_,Exception *nested_)
253 : Error(what_,nested_)
257Magick::ErrorMonitor::~ErrorMonitor() throw()
261Magick::ErrorOption::ErrorOption(
const std::string& what_)
266Magick::ErrorOption::ErrorOption(
const std::string& what_,Exception *nested_)
267 : Error(what_,nested_)
271Magick::ErrorOption::~ErrorOption() throw()
275Magick::ErrorPolicy::ErrorPolicy(
const std::string& what_)
280Magick::ErrorPolicy::ErrorPolicy(
const std::string& what_,Exception *nested_)
281 : Error(what_,nested_)
285Magick::ErrorPolicy::~ErrorPolicy() throw()
290Magick::ErrorRegistry::ErrorRegistry(
const std::string& what_)
295Magick::ErrorRegistry::ErrorRegistry(
const std::string& what_,
297 : Error(what_,nested_)
301Magick::ErrorRegistry::~ErrorRegistry() throw()
305Magick::ErrorResourceLimit::ErrorResourceLimit(
const std::string& what_)
310Magick::ErrorResourceLimit::ErrorResourceLimit(
const std::string& what_,
312 : Error(what_,nested_)
316Magick::ErrorResourceLimit::~ErrorResourceLimit() throw()
320Magick::ErrorStream::ErrorStream(
const std::string& what_)
325Magick::ErrorStream::ErrorStream(
const std::string& what_,Exception *nested_)
326 : Error(what_,nested_)
330Magick::ErrorStream::~ErrorStream() throw()
334Magick::ErrorType::ErrorType(
const std::string& what_)
339Magick::ErrorType::ErrorType(
const std::string& what_,Exception *nested_)
340 : Error(what_,nested_)
344Magick::ErrorType::~ErrorType() throw()
348Magick::ErrorUndefined::ErrorUndefined(
const std::string& what_)
353Magick::ErrorUndefined::ErrorUndefined(
const std::string& what_,
355 : Error(what_,nested_)
359Magick::ErrorUndefined::~ErrorUndefined() throw()
363Magick::ErrorXServer::ErrorXServer(
const std::string& what_)
368Magick::ErrorXServer::ErrorXServer(
const std::string& what_,Exception *nested_)
369 : Error(what_,nested_)
373Magick::ErrorXServer::~ErrorXServer() throw ()
377Magick::Warning::Warning(
const std::string& what_)
382Magick::Warning::Warning(
const std::string& what_,Exception *nested_)
383 : Exception(what_,nested_)
387Magick::Warning::~Warning() throw()
391Magick::WarningBlob::WarningBlob(
const std::string& what_)
396Magick::WarningBlob::WarningBlob(
const std::string& what_,Exception *nested_)
397 : Warning(what_,nested_)
401Magick::WarningBlob::~WarningBlob() throw()
405Magick::WarningCache::WarningCache(
const std::string& what_)
410Magick::WarningCache::WarningCache(
const std::string& what_,Exception *nested_)
411 : Warning(what_,nested_)
415Magick::WarningCache::~WarningCache() throw()
419Magick::WarningCoder::WarningCoder(
const std::string& what_)
424Magick::WarningCoder::WarningCoder(
const std::string& what_,Exception *nested_)
425 : Warning(what_,nested_)
429Magick::WarningCoder::~WarningCoder() throw()
433Magick::WarningConfigure::WarningConfigure(
const std::string& what_)
438Magick::WarningConfigure::WarningConfigure(
const std::string& what_,
440 : Warning(what_,nested_)
444Magick::WarningConfigure::~WarningConfigure() throw()
448Magick::WarningCorruptImage::WarningCorruptImage(
const std::string& what_)
453Magick::WarningCorruptImage::WarningCorruptImage(
const std::string& what_,
455 : Warning(what_,nested_)
459Magick::WarningCorruptImage::~WarningCorruptImage() throw()
463Magick::WarningDelegate::WarningDelegate(
const std::string& what_)
468Magick::WarningDelegate::WarningDelegate(
const std::string& what_,
470 : Warning(what_,nested_)
474Magick::WarningDelegate::~WarningDelegate() throw()
478Magick::WarningDraw::WarningDraw(
const std::string& what_)
483Magick::WarningDraw::WarningDraw(
const std::string& what_,Exception *nested_)
484 : Warning(what_,nested_)
488Magick::WarningDraw::~WarningDraw() throw()
492Magick::WarningFileOpen::WarningFileOpen(
const std::string& what_)
497Magick::WarningFileOpen::WarningFileOpen(
const std::string& what_,
499 : Warning(what_,nested_)
503Magick::WarningFileOpen::~WarningFileOpen() throw()
507Magick::WarningImage::WarningImage(
const std::string& what_)
512Magick::WarningImage::WarningImage(
const std::string& what_,Exception *nested_)
513 : Warning(what_,nested_)
517Magick::WarningImage::~WarningImage() throw()
521Magick::WarningMissingDelegate::WarningMissingDelegate(
522 const std::string& what_)
527Magick::WarningMissingDelegate::WarningMissingDelegate(
528 const std::string& what_,Exception *nested_)
529 : Warning(what_,nested_)
533Magick::WarningMissingDelegate::~WarningMissingDelegate() throw()
537Magick::WarningModule::WarningModule(
const std::string& what_)
542Magick::WarningModule::WarningModule(
const std::string& what_,
544 : Warning(what_,nested_)
549Magick::WarningModule::~WarningModule() throw()
553Magick::WarningMonitor::WarningMonitor(
const std::string& what_)
558Magick::WarningMonitor::WarningMonitor(
const std::string& what_,
560 : Warning(what_,nested_)
564Magick::WarningMonitor::~WarningMonitor() throw()
568Magick::WarningOption::WarningOption(
const std::string& what_)
573Magick::WarningOption::WarningOption(
const std::string& what_,
575 : Warning(what_,nested_)
579Magick::WarningOption::~WarningOption() throw()
583Magick::WarningRegistry::WarningRegistry(
const std::string& what_)
588Magick::WarningRegistry::WarningRegistry(
const std::string& what_,
590 : Warning(what_,nested_)
594Magick::WarningRegistry::~WarningRegistry() throw()
598Magick::WarningPolicy::WarningPolicy(
const std::string& what_)
603Magick::WarningPolicy::WarningPolicy(
const std::string& what_,
605 : Warning(what_,nested_)
609Magick::WarningPolicy::~WarningPolicy() throw()
613Magick::WarningResourceLimit::WarningResourceLimit(
const std::string& what_)
618Magick::WarningResourceLimit::WarningResourceLimit(
const std::string& what_,
620 : Warning(what_,nested_)
624Magick::WarningResourceLimit::~WarningResourceLimit() throw()
628Magick::WarningStream::WarningStream(
const std::string& what_)
633Magick::WarningStream::WarningStream(
const std::string& what_,
635 : Warning(what_,nested_)
639Magick::WarningStream::~WarningStream() throw()
643Magick::WarningType::WarningType(
const std::string& what_)
648Magick::WarningType::WarningType(
const std::string& what_,Exception *nested_)
649 : Warning(what_,nested_)
653Magick::WarningType::~WarningType() throw()
657Magick::WarningUndefined::WarningUndefined(
const std::string& what_)
662Magick::WarningUndefined::WarningUndefined(
const std::string& what_,
664 : Warning(what_,nested_)
668Magick::WarningUndefined::~WarningUndefined() throw()
672Magick::WarningXServer::WarningXServer(
const std::string& what_)
677Magick::WarningXServer::WarningXServer(
const std::string& what_,
679 : Warning(what_,nested_)
683Magick::WarningXServer::~WarningXServer() throw()
687std::string Magick::formatExceptionMessage(
const MagickCore::ExceptionInfo *exception_)
690 std::string message=GetClientName();
691 if (exception_->reason != (
char *) NULL)
693 message+=std::string(
": ");
694 message+=std::string(exception_->reason);
697 if (exception_->description != (
char *) NULL)
698 message +=
" (" + std::string(exception_->description) +
")";
702Magick::Exception* Magick::createException(
const MagickCore::ExceptionInfo *exception_)
704 std::string message=formatExceptionMessage(exception_);
705 switch (exception_->severity)
707 case MagickCore::BlobError:
708 case MagickCore::BlobFatalError:
709 return new ErrorBlob(message);
710 case MagickCore::BlobWarning:
711 return new WarningBlob(message);
712 case MagickCore::CacheError:
713 case MagickCore::CacheFatalError:
714 return new ErrorCache(message);
715 case MagickCore::CacheWarning:
716 return new WarningCache(message);
717 case MagickCore::CoderError:
718 case MagickCore::CoderFatalError:
719 return new ErrorCoder(message);
720 case MagickCore::CoderWarning:
721 return new WarningCoder(message);
722 case MagickCore::ConfigureError:
723 case MagickCore::ConfigureFatalError:
724 return new ErrorConfigure(message);
725 case MagickCore::ConfigureWarning:
726 return new WarningConfigure(message);
727 case MagickCore::CorruptImageError:
728 case MagickCore::CorruptImageFatalError:
729 return new ErrorCorruptImage(message);
730 case MagickCore::CorruptImageWarning:
731 return new WarningCorruptImage(message);
732 case MagickCore::DelegateError:
733 case MagickCore::DelegateFatalError:
734 return new ErrorDelegate(message);
735 case MagickCore::DelegateWarning:
736 return new WarningDelegate(message);
737 case MagickCore::DrawError:
738 case MagickCore::DrawFatalError:
739 return new ErrorDraw(message);
740 case MagickCore::DrawWarning:
741 return new WarningDraw(message);
742 case MagickCore::FileOpenError:
743 case MagickCore::FileOpenFatalError:
744 return new ErrorFileOpen(message);
745 case MagickCore::FileOpenWarning:
746 return new WarningFileOpen(message);
747 case MagickCore::ImageError:
748 case MagickCore::ImageFatalError:
749 return new ErrorImage(message);
750 case MagickCore::ImageWarning:
751 return new WarningImage(message);
752 case MagickCore::MissingDelegateError:
753 case MagickCore::MissingDelegateFatalError:
754 return new ErrorMissingDelegate(message);
755 case MagickCore::MissingDelegateWarning:
756 return new WarningMissingDelegate(message);
757 case MagickCore::ModuleError:
758 case MagickCore::ModuleFatalError:
759 return new ErrorModule(message);
760 case MagickCore::ModuleWarning:
761 return new WarningModule(message);
762 case MagickCore::MonitorError:
763 case MagickCore::MonitorFatalError:
764 return new ErrorMonitor(message);
765 case MagickCore::MonitorWarning:
766 return new WarningMonitor(message);
767 case MagickCore::OptionError:
768 case MagickCore::OptionFatalError:
769 return new ErrorOption(message);
770 case MagickCore::OptionWarning:
771 return new WarningOption(message);
772 case MagickCore::PolicyWarning:
773 return new WarningPolicy(message);
774 case MagickCore::PolicyError:
775 case MagickCore::PolicyFatalError:
776 return new ErrorPolicy(message);
777 case MagickCore::RegistryError:
778 case MagickCore::RegistryFatalError:
779 return new ErrorRegistry(message);
780 case MagickCore::RegistryWarning:
781 return new WarningRegistry(message);
782 case MagickCore::ResourceLimitError:
783 case MagickCore::ResourceLimitFatalError:
784 return new ErrorResourceLimit(message);
785 case MagickCore::ResourceLimitWarning:
786 return new WarningResourceLimit(message);
787 case MagickCore::StreamError:
788 case MagickCore::StreamFatalError:
789 return new ErrorStream(message);
790 case MagickCore::StreamWarning:
791 return new WarningStream(message);
792 case MagickCore::TypeError:
793 case MagickCore::TypeFatalError:
794 return new ErrorType(message);
795 case MagickCore::TypeWarning:
796 return new WarningType(message);
797 case MagickCore::UndefinedException:
799 return new ErrorUndefined(message);
800 case MagickCore::XServerError:
801 case MagickCore::XServerFatalError:
802 return new ErrorXServer(message);
803 case MagickCore::XServerWarning:
804 return new WarningXServer(message);
808MagickPPExport
void Magick::throwExceptionExplicit(
809 const MagickCore::ExceptionType severity_,
const char* reason_,
810 const char* description_)
813 if (severity_ == MagickCore::UndefinedException)
817 ThrowException(exceptionInfo,severity_,reason_,description_);
818 ThrowPPException(
false);
821MagickPPExport
void Magick::throwException(ExceptionInfo *exception_,
831 MagickCore::ExceptionType
841 if (exception_->severity == MagickCore::UndefinedException)
844 message=formatExceptionMessage(exception_);
845 nestedException=(Exception *) NULL;
846 q=(Exception *) NULL;
847 LockSemaphoreInfo(exception_->semaphore);
848 if (exception_->exceptions != (
void *) NULL)
850 index=GetNumberOfElementsInLinkedList((LinkedListInfo *)
851 exception_->exceptions);
854 p=(
const ExceptionInfo *) GetValueFromLinkedList((LinkedListInfo *)
855 exception_->exceptions,--index);
856 if ((p->severity != exception_->severity) || (LocaleCompare(p->reason,
857 exception_->reason) != 0) || (LocaleCompare(p->description,
858 exception_->description) != 0))
860 if (nestedException == (Exception *) NULL)
862 nestedException=createException(p);
870 r=createException(p);
877 severity=exception_->severity;
878 UnlockSemaphoreInfo(exception_->semaphore);
880 if ((quiet_) && (severity < MagickCore::ErrorException))
882 delete nestedException;
886 DestroyExceptionInfo(exception_);
890 case MagickCore::BlobError:
891 case MagickCore::BlobFatalError:
892 throw ErrorBlob(message,nestedException);
893 case MagickCore::BlobWarning:
894 throw WarningBlob(message,nestedException);
895 case MagickCore::CacheError:
896 case MagickCore::CacheFatalError:
897 throw ErrorCache(message,nestedException);
898 case MagickCore::CacheWarning:
899 throw WarningCache(message,nestedException);
900 case MagickCore::CoderError:
901 case MagickCore::CoderFatalError:
902 throw ErrorCoder(message,nestedException);
903 case MagickCore::CoderWarning:
904 throw WarningCoder(message,nestedException);
905 case MagickCore::ConfigureError:
906 case MagickCore::ConfigureFatalError:
907 throw ErrorConfigure(message,nestedException);
908 case MagickCore::ConfigureWarning:
909 throw WarningConfigure(message,nestedException);
910 case MagickCore::CorruptImageError:
911 case MagickCore::CorruptImageFatalError:
912 throw ErrorCorruptImage(message,nestedException);
913 case MagickCore::CorruptImageWarning:
914 throw WarningCorruptImage(message,nestedException);
915 case MagickCore::DelegateError:
916 case MagickCore::DelegateFatalError:
917 throw ErrorDelegate(message,nestedException);
918 case MagickCore::DelegateWarning:
919 throw WarningDelegate(message,nestedException);
920 case MagickCore::DrawError:
921 case MagickCore::DrawFatalError:
922 throw ErrorDraw(message,nestedException);
923 case MagickCore::DrawWarning:
924 throw WarningDraw(message,nestedException);
925 case MagickCore::FileOpenError:
926 case MagickCore::FileOpenFatalError:
927 throw ErrorFileOpen(message,nestedException);
928 case MagickCore::FileOpenWarning:
929 throw WarningFileOpen(message,nestedException);
930 case MagickCore::ImageError:
931 case MagickCore::ImageFatalError:
932 throw ErrorImage(message,nestedException);
933 case MagickCore::ImageWarning:
934 throw WarningImage(message,nestedException);
935 case MagickCore::MissingDelegateError:
936 case MagickCore::MissingDelegateFatalError:
937 throw ErrorMissingDelegate(message,nestedException);
938 case MagickCore::MissingDelegateWarning:
939 throw WarningMissingDelegate(message,nestedException);
940 case MagickCore::ModuleError:
941 case MagickCore::ModuleFatalError:
942 throw ErrorModule(message,nestedException);
943 case MagickCore::ModuleWarning:
944 throw WarningModule(message,nestedException);
945 case MagickCore::MonitorError:
946 case MagickCore::MonitorFatalError:
947 throw ErrorMonitor(message,nestedException);
948 case MagickCore::MonitorWarning:
949 throw WarningMonitor(message,nestedException);
950 case MagickCore::OptionError:
951 case MagickCore::OptionFatalError:
952 throw ErrorOption(message,nestedException);
953 case MagickCore::OptionWarning:
954 throw WarningOption(message,nestedException);
955 case MagickCore::PolicyWarning:
956 throw WarningPolicy(message,nestedException);
957 case MagickCore::PolicyError:
958 case MagickCore::PolicyFatalError:
959 throw ErrorPolicy(message,nestedException);
960 case MagickCore::RegistryError:
961 case MagickCore::RegistryFatalError:
962 throw ErrorRegistry(message,nestedException);
963 case MagickCore::RegistryWarning:
964 throw WarningRegistry(message,nestedException);
965 case MagickCore::ResourceLimitError:
966 case MagickCore::ResourceLimitFatalError:
967 throw ErrorResourceLimit(message,nestedException);
968 case MagickCore::ResourceLimitWarning:
969 throw WarningResourceLimit(message,nestedException);
970 case MagickCore::StreamError:
971 case MagickCore::StreamFatalError:
972 throw ErrorStream(message,nestedException);
973 case MagickCore::StreamWarning:
974 throw WarningStream(message,nestedException);
975 case MagickCore::TypeError:
976 case MagickCore::TypeFatalError:
977 throw ErrorType(message,nestedException);
978 case MagickCore::TypeWarning:
979 throw WarningType(message,nestedException);
980 case MagickCore::UndefinedException:
982 throw ErrorUndefined(message,nestedException);
983 case MagickCore::XServerError:
984 case MagickCore::XServerFatalError:
985 throw ErrorXServer(message,nestedException);
986 case MagickCore::XServerWarning:
987 throw WarningXServer(message,nestedException);