exception.h 4.5 KB

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