cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
Cristy | f6ff9ea | 2016-12-05 09:53:35 -0500 | [diff] [blame] | 2 | Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3 | dedicated to making software imaging solutions freely available. |
| 4 | |
| 5 | You may not use this file except in compliance with the License. |
| 6 | obtain a copy of the License at |
| 7 | |
Cristy | f19d414 | 2017-04-24 11:34:30 -0400 | [diff] [blame^] | 8 | https://www.imagemagick.org/script/license.php |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | MagickCore exception methods. |
| 17 | */ |
Cristy | 83bceaa | 2016-06-03 20:39:35 -0400 | [diff] [blame] | 18 | #ifndef MAGICKCORE_EXCEPTION_H |
| 19 | #define MAGICKCORE_EXCEPTION_H |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 20 | |
cristy | 6398ec7 | 2013-11-28 02:00:27 +0000 | [diff] [blame] | 21 | #include "MagickCore/semaphore.h" |
| 22 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 23 | #if defined(__cplusplus) || defined(c_plusplus) |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 27 | typedef enum |
| 28 | { |
| 29 | UndefinedException, |
| 30 | WarningException = 300, |
| 31 | ResourceLimitWarning = 300, |
| 32 | TypeWarning = 305, |
| 33 | OptionWarning = 310, |
| 34 | DelegateWarning = 315, |
| 35 | MissingDelegateWarning = 320, |
| 36 | CorruptImageWarning = 325, |
| 37 | FileOpenWarning = 330, |
| 38 | BlobWarning = 335, |
| 39 | StreamWarning = 340, |
| 40 | CacheWarning = 345, |
| 41 | CoderWarning = 350, |
cristy | 992729d | 2010-01-01 15:45:06 +0000 | [diff] [blame] | 42 | FilterWarning = 352, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 43 | ModuleWarning = 355, |
| 44 | DrawWarning = 360, |
| 45 | ImageWarning = 365, |
| 46 | WandWarning = 370, |
| 47 | RandomWarning = 375, |
| 48 | XServerWarning = 380, |
| 49 | MonitorWarning = 385, |
| 50 | RegistryWarning = 390, |
| 51 | ConfigureWarning = 395, |
| 52 | PolicyWarning = 399, |
| 53 | ErrorException = 400, |
| 54 | ResourceLimitError = 400, |
| 55 | TypeError = 405, |
| 56 | OptionError = 410, |
| 57 | DelegateError = 415, |
| 58 | MissingDelegateError = 420, |
| 59 | CorruptImageError = 425, |
| 60 | FileOpenError = 430, |
| 61 | BlobError = 435, |
| 62 | StreamError = 440, |
| 63 | CacheError = 445, |
| 64 | CoderError = 450, |
cristy | 992729d | 2010-01-01 15:45:06 +0000 | [diff] [blame] | 65 | FilterError = 452, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | ModuleError = 455, |
| 67 | DrawError = 460, |
| 68 | ImageError = 465, |
| 69 | WandError = 470, |
| 70 | RandomError = 475, |
| 71 | XServerError = 480, |
| 72 | MonitorError = 485, |
| 73 | RegistryError = 490, |
| 74 | ConfigureError = 495, |
| 75 | PolicyError = 499, |
| 76 | FatalErrorException = 700, |
| 77 | ResourceLimitFatalError = 700, |
| 78 | TypeFatalError = 705, |
| 79 | OptionFatalError = 710, |
| 80 | DelegateFatalError = 715, |
| 81 | MissingDelegateFatalError = 720, |
| 82 | CorruptImageFatalError = 725, |
| 83 | FileOpenFatalError = 730, |
| 84 | BlobFatalError = 735, |
| 85 | StreamFatalError = 740, |
| 86 | CacheFatalError = 745, |
| 87 | CoderFatalError = 750, |
cristy | 992729d | 2010-01-01 15:45:06 +0000 | [diff] [blame] | 88 | FilterFatalError = 752, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 89 | ModuleFatalError = 755, |
| 90 | DrawFatalError = 760, |
| 91 | ImageFatalError = 765, |
| 92 | WandFatalError = 770, |
| 93 | RandomFatalError = 775, |
| 94 | XServerFatalError = 780, |
| 95 | MonitorFatalError = 785, |
| 96 | RegistryFatalError = 790, |
| 97 | ConfigureFatalError = 795, |
| 98 | PolicyFatalError = 799 |
| 99 | } ExceptionType; |
| 100 | |
| 101 | struct _ExceptionInfo |
| 102 | { |
| 103 | ExceptionType |
| 104 | severity; |
| 105 | |
| 106 | int |
| 107 | error_number; |
| 108 | |
| 109 | char |
| 110 | *reason, |
| 111 | *description; |
| 112 | |
| 113 | void |
| 114 | *exceptions; |
| 115 | |
| 116 | MagickBooleanType |
| 117 | relinquish; |
| 118 | |
| 119 | SemaphoreInfo |
| 120 | *semaphore; |
| 121 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 122 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 123 | signature; |
| 124 | }; |
| 125 | |
| 126 | typedef void |
| 127 | (*ErrorHandler)(const ExceptionType,const char *,const char *); |
| 128 | |
| 129 | typedef void |
| 130 | (*FatalErrorHandler)(const ExceptionType,const char *,const char *); |
| 131 | |
| 132 | typedef void |
| 133 | (*WarningHandler)(const ExceptionType,const char *,const char *); |
| 134 | |
| 135 | extern MagickExport char |
| 136 | *GetExceptionMessage(const int); |
| 137 | |
| 138 | extern MagickExport const char |
| 139 | *GetLocaleExceptionMessage(const ExceptionType,const char *); |
| 140 | |
| 141 | extern MagickExport ErrorHandler |
| 142 | SetErrorHandler(ErrorHandler); |
| 143 | |
| 144 | extern MagickExport ExceptionInfo |
| 145 | *AcquireExceptionInfo(void), |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 146 | *CloneExceptionInfo(ExceptionInfo *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 147 | *DestroyExceptionInfo(ExceptionInfo *); |
| 148 | |
| 149 | extern MagickExport FatalErrorHandler |
| 150 | SetFatalErrorHandler(FatalErrorHandler); |
| 151 | |
| 152 | extern MagickExport MagickBooleanType |
| 153 | ThrowException(ExceptionInfo *,const ExceptionType,const char *, |
| 154 | const char *), |
cristy | b200b6c | 2012-12-13 15:20:26 +0000 | [diff] [blame] | 155 | ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *, |
| 156 | const size_t,const ExceptionType,const char *,const char *,va_list), |
cristy | 5ed838e | 2010-05-31 00:05:35 +0000 | [diff] [blame] | 157 | ThrowMagickException(ExceptionInfo *,const char *,const char *,const size_t, |
| 158 | const ExceptionType,const char *,const char *,...) |
cristy | 7338053 | 2012-02-18 20:26:28 +0000 | [diff] [blame] | 159 | magick_attribute((__format__ (__printf__,7,8))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 160 | |
| 161 | extern MagickExport void |
| 162 | CatchException(ExceptionInfo *), |
| 163 | ClearMagickException(ExceptionInfo *), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 164 | InheritException(ExceptionInfo *,const ExceptionInfo *), |
| 165 | MagickError(const ExceptionType,const char *,const char *), |
| 166 | MagickFatalError(const ExceptionType,const char *,const char *), |
| 167 | MagickWarning(const ExceptionType,const char *,const char *); |
| 168 | |
| 169 | extern MagickExport WarningHandler |
| 170 | SetWarningHandler(WarningHandler); |
| 171 | |
| 172 | #if defined(__cplusplus) || defined(c_plusplus) |
| 173 | } |
| 174 | #endif |
| 175 | |
| 176 | #endif |