Home | History | Annotate | Download | only in MagickCore
      1 /*
      2   Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization
      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 #include "MagickCore/semaphore.h"
     22 
     23 #if defined(__cplusplus) || defined(c_plusplus)
     24 extern "C" {
     25 #endif
     26 
     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,
     42   FilterWarning = 352,
     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,
     65   FilterError = 452,
     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,
     88   FilterFatalError = 752,
     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 
    122   size_t
    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),
    146   *CloneExceptionInfo(ExceptionInfo *),
    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   ThrowMagickExceptionList(ExceptionInfo *,const char *,const char *,
    156     const size_t,const ExceptionType,const char *,const char *,va_list),
    157   ThrowMagickException(ExceptionInfo *,const char *,const char *,const size_t,
    158     const ExceptionType,const char *,const char *,...)
    159     magick_attribute((__format__ (__printf__,7,8)));
    160 
    161 extern MagickExport void
    162   CatchException(ExceptionInfo *),
    163   ClearMagickException(ExceptionInfo *),
    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
    177