cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
cristy | 16af1cb | 2009-12-11 21:38:29 +0000 | [diff] [blame] | 2 | Copyright 1999-2010 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 | |
| 8 | http://www.imagemagick.org/script/license.php |
| 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 | */ |
| 18 | #ifndef _MAGICKCORE_EXCEPTION_H |
| 19 | #define _MAGICKCORE_EXCEPTION_H |
| 20 | |
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | #include <stdarg.h> |
| 26 | #include "magick/semaphore.h" |
| 27 | |
| 28 | typedef enum |
| 29 | { |
| 30 | UndefinedException, |
| 31 | WarningException = 300, |
| 32 | ResourceLimitWarning = 300, |
| 33 | TypeWarning = 305, |
| 34 | OptionWarning = 310, |
| 35 | DelegateWarning = 315, |
| 36 | MissingDelegateWarning = 320, |
| 37 | CorruptImageWarning = 325, |
| 38 | FileOpenWarning = 330, |
| 39 | BlobWarning = 335, |
| 40 | StreamWarning = 340, |
| 41 | CacheWarning = 345, |
| 42 | CoderWarning = 350, |
cristy | 992729d | 2010-01-01 15:45:06 +0000 | [diff] [blame] | 43 | FilterWarning = 352, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 44 | ModuleWarning = 355, |
| 45 | DrawWarning = 360, |
| 46 | ImageWarning = 365, |
| 47 | WandWarning = 370, |
| 48 | RandomWarning = 375, |
| 49 | XServerWarning = 380, |
| 50 | MonitorWarning = 385, |
| 51 | RegistryWarning = 390, |
| 52 | ConfigureWarning = 395, |
| 53 | PolicyWarning = 399, |
| 54 | ErrorException = 400, |
| 55 | ResourceLimitError = 400, |
| 56 | TypeError = 405, |
| 57 | OptionError = 410, |
| 58 | DelegateError = 415, |
| 59 | MissingDelegateError = 420, |
| 60 | CorruptImageError = 425, |
| 61 | FileOpenError = 430, |
| 62 | BlobError = 435, |
| 63 | StreamError = 440, |
| 64 | CacheError = 445, |
| 65 | CoderError = 450, |
cristy | 992729d | 2010-01-01 15:45:06 +0000 | [diff] [blame] | 66 | FilterError = 452, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | ModuleError = 455, |
| 68 | DrawError = 460, |
| 69 | ImageError = 465, |
| 70 | WandError = 470, |
| 71 | RandomError = 475, |
| 72 | XServerError = 480, |
| 73 | MonitorError = 485, |
| 74 | RegistryError = 490, |
| 75 | ConfigureError = 495, |
| 76 | PolicyError = 499, |
| 77 | FatalErrorException = 700, |
| 78 | ResourceLimitFatalError = 700, |
| 79 | TypeFatalError = 705, |
| 80 | OptionFatalError = 710, |
| 81 | DelegateFatalError = 715, |
| 82 | MissingDelegateFatalError = 720, |
| 83 | CorruptImageFatalError = 725, |
| 84 | FileOpenFatalError = 730, |
| 85 | BlobFatalError = 735, |
| 86 | StreamFatalError = 740, |
| 87 | CacheFatalError = 745, |
| 88 | CoderFatalError = 750, |
cristy | 992729d | 2010-01-01 15:45:06 +0000 | [diff] [blame] | 89 | FilterFatalError = 752, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 90 | ModuleFatalError = 755, |
| 91 | DrawFatalError = 760, |
| 92 | ImageFatalError = 765, |
| 93 | WandFatalError = 770, |
| 94 | RandomFatalError = 775, |
| 95 | XServerFatalError = 780, |
| 96 | MonitorFatalError = 785, |
| 97 | RegistryFatalError = 790, |
| 98 | ConfigureFatalError = 795, |
| 99 | PolicyFatalError = 799 |
| 100 | } ExceptionType; |
| 101 | |
| 102 | struct _ExceptionInfo |
| 103 | { |
| 104 | ExceptionType |
| 105 | severity; |
| 106 | |
| 107 | int |
| 108 | error_number; |
| 109 | |
| 110 | char |
| 111 | *reason, |
| 112 | *description; |
| 113 | |
| 114 | void |
| 115 | *exceptions; |
| 116 | |
| 117 | MagickBooleanType |
| 118 | relinquish; |
| 119 | |
| 120 | SemaphoreInfo |
| 121 | *semaphore; |
| 122 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame^] | 123 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 124 | signature; |
| 125 | }; |
| 126 | |
| 127 | typedef void |
| 128 | (*ErrorHandler)(const ExceptionType,const char *,const char *); |
| 129 | |
| 130 | typedef void |
| 131 | (*FatalErrorHandler)(const ExceptionType,const char *,const char *); |
| 132 | |
| 133 | typedef void |
| 134 | (*WarningHandler)(const ExceptionType,const char *,const char *); |
| 135 | |
| 136 | extern MagickExport char |
| 137 | *GetExceptionMessage(const int); |
| 138 | |
| 139 | extern MagickExport const char |
| 140 | *GetLocaleExceptionMessage(const ExceptionType,const char *); |
| 141 | |
| 142 | extern MagickExport ErrorHandler |
| 143 | SetErrorHandler(ErrorHandler); |
| 144 | |
| 145 | extern MagickExport ExceptionInfo |
| 146 | *AcquireExceptionInfo(void), |
| 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 *), |
| 155 | ThrowMagickException(ExceptionInfo *,const char *,const char *, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame^] | 156 | const size_t,const ExceptionType,const char *,const char *,...) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 157 | magick_attribute((format (printf,7,8))), |
| 158 | ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame^] | 159 | const size_t,const ExceptionType,const char *,const char *,va_list) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 160 | magick_attribute((format (printf,7,0))); |
| 161 | |
| 162 | extern MagickExport void |
| 163 | CatchException(ExceptionInfo *), |
| 164 | ClearMagickException(ExceptionInfo *), |
| 165 | GetExceptionInfo(ExceptionInfo *), |
| 166 | InheritException(ExceptionInfo *,const ExceptionInfo *), |
| 167 | MagickError(const ExceptionType,const char *,const char *), |
| 168 | MagickFatalError(const ExceptionType,const char *,const char *), |
| 169 | MagickWarning(const ExceptionType,const char *,const char *); |
| 170 | |
| 171 | extern MagickExport WarningHandler |
| 172 | SetWarningHandler(WarningHandler); |
| 173 | |
| 174 | #if defined(__cplusplus) || defined(c_plusplus) |
| 175 | } |
| 176 | #endif |
| 177 | |
| 178 | #endif |