Home | History | Annotate | Download | only in api
      1 
      2 
      3 
      4 
      5 <!DOCTYPE html>
      6 <html lang="en">
      7 <head>
      8     <title>ImageMagick: MagickCore, C API for ImageMagick: Dealing with Exceptions</title>
      9   <meta charset="utf-8" />
     10   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     11   <meta name="viewport" content="width=device-width, initial-scale=1" />
     12   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     13   <meta name="application-name" content="ImageMagick"/>
     14   <meta name="description" content="ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bzier curves."/>
     15   <meta name="application-url" content="http://www.imagemagick.org"/>
     16   <meta name="generator" content="PHP"/>
     17   <meta name="keywords" content="magickcore, c, api, for, imagemagick:, dealing, with, exceptions, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
     18   <meta name="rating" content="GENERAL"/>
     19   <meta name="robots" content="INDEX, FOLLOW"/>
     20   <meta name="generator" content="ImageMagick Studio LLC"/>
     21   <meta name="author" content="ImageMagick Studio LLC"/>
     22   <meta name="revisit-after" content="2 DAYS"/>
     23   <meta name="resource-type" content="document"/>
     24   <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
     25   <meta name="distribution" content="Global"/>
     26   <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
     27   <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
     28   <link rel="icon" href="../images/wand.png"/>
     29   <link rel="shortcut icon" href="../images/wand.ico"/>
     30   <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
     31   <link rel="stylesheet" href="../css/magick.html"/>
     32 </head>
     33 <body>
     34 <div class="main">
     35 <div class="magick-masthead">
     36   <div class="container">
     37     <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
     38          style="display:block"
     39          data-ad-client="ca-pub-3129977114552745"
     40          data-ad-slot="6345125851"
     41          data-ad-format="auto"></ins>
     42     <script>
     43       (adsbygoogle = window.adsbygoogle || []).push({});
     44     </script>
     45     <nav class="magick-nav">
     46       <a class="magick-nav-item " href="../index.html">Home</a>
     47       <a class="magick-nav-item " href="../binary-releases.html">Download</a>
     48       <a class="magick-nav-item " href="../command-line-tools.html">Tools</a>
     49       <a class="magick-nav-item " href="../command-line-processing.html">Command-line</a>
     50       <a class="magick-nav-item " href="../resources.html">Resources</a>
     51       <a class="magick-nav-item " href="api.html">Develop</a>
     52       <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
     53       <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
     54     </nav>
     55   </div>
     56 </div>
     57 <div class="container">
     58 <div class="magick-header">
     59 <p class="text-center"><a href="exception.html#AcquireExceptionInfo">AcquireExceptionInfo</a> &#8226; <a href="exception.html#ClearMagickException">ClearMagickException</a> &#8226; <a href="exception.html#CatchException">CatchException</a> &#8226; <a href="exception.html#CloneExceptionInfo">CloneExceptionInfo</a> &#8226; <a href="exception.html#DestroyExceptionInfo">DestroyExceptionInfo</a> &#8226; <a href="exception.html#GetExceptionMessage">GetExceptionMessage</a> &#8226; <a href="exception.html#GetLocaleExceptionMessage">GetLocaleExceptionMessage</a> &#8226; <a href="exception.html#InheritException">InheritException</a> &#8226; <a href="exception.html#InitializeExceptionInfo">InitializeExceptionInfo</a> &#8226; <a href="exception.html#MagickError">MagickError</a> &#8226; <a href="exception.html#MagickFatalError">MagickFatalError</a> &#8226; <a href="exception.html#MagickWarning">MagickWarning</a> &#8226; <a href="exception.html#SetErrorHandler">SetErrorHandler</a> &#8226; <a href="exception.html#SetFatalErrorHandler">SetFatalErrorHandler</a> &#8226; <a href="exception.html#SetWarningHandler">SetWarningHandler</a> &#8226; <a href="exception.html#ThrowException">ThrowException</a></p>
     60 
     61 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="AcquireExceptionInfo">AcquireExceptionInfo</a></h2>
     62 
     63 <p>AcquireExceptionInfo() allocates the ExceptionInfo structure.</p>
     64 
     65 <p>The format of the AcquireExceptionInfo method is:</p>
     66 
     67 <pre class="text">
     68 ExceptionInfo *AcquireExceptionInfo(void)
     69 </pre>
     70 
     71 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="ClearMagickException">ClearMagickException</a></h2>
     72 
     73 <p>ClearMagickException() clears any exception that may not have been caught yet.</p>
     74 
     75 <p>The format of the ClearMagickException method is:</p>
     76 
     77 <pre class="text">
     78 ClearMagickException(ExceptionInfo *exception)
     79 </pre>
     80 
     81 <p>A description of each parameter follows:</p>
     82 
     83 <dd>
     84 </dd>
     85 
     86 <dd> </dd>
     87 <dl class="dl-horizontal">
     88 <dt>exception</dt>
     89 <dd>the exception info. </dd>
     90 
     91 <dd>  </dd>
     92 </dl>
     93 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="CatchException">CatchException</a></h2>
     94 
     95 <p>CatchException() returns if no exceptions is found otherwise it reports the exception as a warning, error, or fatal depending on the severity.</p>
     96 
     97 <p>The format of the CatchException method is:</p>
     98 
     99 <pre class="text">
    100 CatchException(ExceptionInfo *exception)
    101 </pre>
    102 
    103 <p>A description of each parameter follows:</p>
    104 
    105 <dd>
    106 </dd>
    107 
    108 <dd> </dd>
    109 <dl class="dl-horizontal">
    110 <dt>exception</dt>
    111 <dd>the exception info. </dd>
    112 
    113 <dd>  </dd>
    114 </dl>
    115 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="CloneExceptionInfo">CloneExceptionInfo</a></h2>
    116 
    117 <p>CloneExceptionInfo() clones the ExceptionInfo structure.</p>
    118 
    119 <p>The format of the CloneExceptionInfo method is:</p>
    120 
    121 <pre class="text">
    122 ExceptionInfo *CloneException(ExceptionInfo *exception)
    123 </pre>
    124 
    125 <p>A description of each parameter follows:</p>
    126 
    127 <dd>
    128 </dd>
    129 
    130 <dd> </dd>
    131 <dl class="dl-horizontal">
    132 <dt>exception</dt>
    133 <dd>the exception info. </dd>
    134 
    135 <dd>  </dd>
    136 </dl>
    137 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="DestroyExceptionInfo">DestroyExceptionInfo</a></h2>
    138 
    139 <p>DestroyExceptionInfo() deallocates memory associated with an exception.</p>
    140 
    141 <p>The format of the DestroyExceptionInfo method is:</p>
    142 
    143 <pre class="text">
    144 ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception)
    145 </pre>
    146 
    147 <p>A description of each parameter follows:</p>
    148 
    149 <dd>
    150 </dd>
    151 
    152 <dd> </dd>
    153 <dl class="dl-horizontal">
    154 <dt>exception</dt>
    155 <dd>the exception info. </dd>
    156 
    157 <dd>  </dd>
    158 </dl>
    159 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="GetExceptionMessage">GetExceptionMessage</a></h2>
    160 
    161 <p>GetExceptionMessage() returns the error message defined by the specified error code.</p>
    162 
    163 <p>The format of the GetExceptionMessage method is:</p>
    164 
    165 <pre class="text">
    166 char *GetExceptionMessage(const int error)
    167 </pre>
    168 
    169 <p>A description of each parameter follows:</p>
    170 
    171 <dd>
    172 </dd>
    173 
    174 <dd> </dd>
    175 <dl class="dl-horizontal">
    176 <dt>error</dt>
    177 <dd>the error code. </dd>
    178 
    179 <dd>  </dd>
    180 </dl>
    181 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="GetLocaleExceptionMessage">GetLocaleExceptionMessage</a></h2>
    182 
    183 <p>GetLocaleExceptionMessage() converts a enumerated exception severity and tag to a message in the current locale.</p>
    184 
    185 <p>The format of the GetLocaleExceptionMessage method is:</p>
    186 
    187 <pre class="text">
    188 const char *GetLocaleExceptionMessage(const ExceptionType severity,
    189   const char *tag)
    190 </pre>
    191 
    192 <p>A description of each parameter follows:</p>
    193 
    194 <dd>
    195 </dd>
    196 
    197 <dd> </dd>
    198 <dl class="dl-horizontal">
    199 <dt>severity</dt>
    200 <dd>the severity of the exception. </dd>
    201 
    202 <dd> </dd>
    203 <dt>tag</dt>
    204 <dd>the message tag. </dd>
    205 
    206 <dd>  </dd>
    207 </dl>
    208 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="InheritException">InheritException</a></h2>
    209 
    210 <p>InheritException() inherits an exception from a related exception.</p>
    211 
    212 <p>The format of the InheritException method is:</p>
    213 
    214 <pre class="text">
    215 InheritException(ExceptionInfo *exception,const ExceptionInfo *relative)
    216 </pre>
    217 
    218 <p>A description of each parameter follows:</p>
    219 
    220 <dd>
    221 </dd>
    222 
    223 <dd> </dd>
    224 <dl class="dl-horizontal">
    225 <dt>exception</dt>
    226 <dd>the exception info. </dd>
    227 
    228 <dd> </dd>
    229 <dt>relative</dt>
    230 <dd>the related exception info. </dd>
    231 
    232 <dd>  </dd>
    233 </dl>
    234 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="InitializeExceptionInfo">InitializeExceptionInfo</a></h2>
    235 
    236 <p>InitializeExceptionInfo() initializes an exception to default values.</p>
    237 
    238 <p>The format of the InitializeExceptionInfo method is:</p>
    239 
    240 <pre class="text">
    241 InitializeExceptionInfo(ExceptionInfo *exception)
    242 </pre>
    243 
    244 <p>A description of each parameter follows:</p>
    245 
    246 <dd>
    247 </dd>
    248 
    249 <dd> </dd>
    250 <dl class="dl-horizontal">
    251 <dt>exception</dt>
    252 <dd>the exception info. </dd>
    253 
    254 <dd>  </dd>
    255 </dl>
    256 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="MagickError">MagickError</a></h2>
    257 
    258 <p>MagickError() calls the exception handler methods with an error reason.</p>
    259 
    260 <p>The format of the MagickError method is:</p>
    261 
    262 <pre class="text">
    263 void MagickError(const ExceptionType error,const char *reason,
    264   const char *description)
    265 </pre>
    266 
    267 <p>A description of each parameter follows:</p>
    268 
    269 <dd>
    270 </dd>
    271 
    272 <dd> </dd>
    273 <dl class="dl-horizontal">
    274 <dt>exception</dt>
    275 <dd>Specifies the numeric error category. </dd>
    276 
    277 <dd> </dd>
    278 <dt>reason</dt>
    279 <dd>Specifies the reason to display before terminating the program. </dd>
    280 
    281 <dd> </dd>
    282 <dt>description</dt>
    283 <dd>Specifies any description to the reason. </dd>
    284 
    285 <dd>  </dd>
    286 </dl>
    287 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="MagickFatalError">MagickFatalError</a></h2>
    288 
    289 <p>MagickFatalError() calls the fatal exception handler methods with an error reason.</p>
    290 
    291 <p>The format of the MagickError method is:</p>
    292 
    293 <pre class="text">
    294 void MagickFatalError(const ExceptionType error,const char *reason,
    295   const char *description)
    296 </pre>
    297 
    298 <p>A description of each parameter follows:</p>
    299 
    300 <dd>
    301 </dd>
    302 
    303 <dd> </dd>
    304 <dl class="dl-horizontal">
    305 <dt>exception</dt>
    306 <dd>Specifies the numeric error category. </dd>
    307 
    308 <dd> </dd>
    309 <dt>reason</dt>
    310 <dd>Specifies the reason to display before terminating the program. </dd>
    311 
    312 <dd> </dd>
    313 <dt>description</dt>
    314 <dd>Specifies any description to the reason. </dd>
    315 
    316 <dd>  </dd>
    317 </dl>
    318 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="MagickWarning">MagickWarning</a></h2>
    319 
    320 <p>MagickWarning() calls the warning handler methods with a warning reason.</p>
    321 
    322 <p>The format of the MagickWarning method is:</p>
    323 
    324 <pre class="text">
    325 void MagickWarning(const ExceptionType warning,const char *reason,
    326   const char *description)
    327 </pre>
    328 
    329 <p>A description of each parameter follows:</p>
    330 
    331 <dd>
    332 </dd>
    333 
    334 <dd> </dd>
    335 <dl class="dl-horizontal">
    336 <dt>warning</dt>
    337 <dd>the warning severity. </dd>
    338 
    339 <dd> </dd>
    340 <dt>reason</dt>
    341 <dd>Define the reason for the warning. </dd>
    342 
    343 <dd> </dd>
    344 <dt>description</dt>
    345 <dd>Describe the warning. </dd>
    346 
    347 <dd>  </dd>
    348 </dl>
    349 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="SetErrorHandler">SetErrorHandler</a></h2>
    350 
    351 <p>SetErrorHandler() sets the exception handler to the specified method and returns the previous exception handler.</p>
    352 
    353 <p>The format of the SetErrorHandler method is:</p>
    354 
    355 <pre class="text">
    356 ErrorHandler SetErrorHandler(ErrorHandler handler)
    357 </pre>
    358 
    359 <p>A description of each parameter follows:</p>
    360 
    361 <dd>
    362 </dd>
    363 
    364 <dd> </dd>
    365 <dl class="dl-horizontal">
    366 <dt>handler</dt>
    367 <dd>the method to handle errors. </dd>
    368 
    369 <dd>  </dd>
    370 </dl>
    371 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="SetFatalErrorHandler">SetFatalErrorHandler</a></h2>
    372 
    373 <p>SetFatalErrorHandler() sets the fatal exception handler to the specified method and returns the previous fatal exception handler.</p>
    374 
    375 <p>The format of the SetErrorHandler method is:</p>
    376 
    377 <pre class="text">
    378 ErrorHandler SetErrorHandler(ErrorHandler handler)
    379 </pre>
    380 
    381 <p>A description of each parameter follows:</p>
    382 
    383 <dd>
    384 </dd>
    385 
    386 <dd> </dd>
    387 <dl class="dl-horizontal">
    388 <dt>handler</dt>
    389 <dd>the method to handle errors. </dd>
    390 
    391 <dd>  </dd>
    392 </dl>
    393 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="SetWarningHandler">SetWarningHandler</a></h2>
    394 
    395 <p>SetWarningHandler() sets the warning handler to the specified method and returns the previous warning handler.</p>
    396 
    397 <p>The format of the SetWarningHandler method is:</p>
    398 
    399 <pre class="text">
    400 ErrorHandler SetWarningHandler(ErrorHandler handler)
    401 </pre>
    402 
    403 <p>A description of each parameter follows:</p>
    404 
    405 <dd>
    406 </dd>
    407 
    408 <dd> </dd>
    409 <dl class="dl-horizontal">
    410 <dt>handler</dt>
    411 <dd>the method to handle warnings. </dd>
    412 
    413 <dd>  </dd>
    414 </dl>
    415 <h2><a href="http://www.imagemagick.org/api/MagickCore/exception_8c.html" id="ThrowException">ThrowException</a></h2>
    416 
    417 <p>ThrowException() throws an exception with the specified severity code, reason, and optional description.</p>
    418 
    419 <p>The format of the ThrowException method is:</p>
    420 
    421 <pre class="text">
    422 MagickBooleanType ThrowException(ExceptionInfo *exception,
    423   const ExceptionType severity,const char *reason,
    424   const char *description)
    425 </pre>
    426 
    427 <p>A description of each parameter follows:</p>
    428 
    429 <dd>
    430 </dd>
    431 
    432 <dd> </dd>
    433 <dl class="dl-horizontal">
    434 <dt>exception</dt>
    435 <dd>the exception info. </dd>
    436 
    437 <dd> </dd>
    438 <dt>severity</dt>
    439 <dd>the severity of the exception. </dd>
    440 
    441 <dd> </dd>
    442 <dt>reason</dt>
    443 <dd>the reason for the exception. </dd>
    444 
    445 <dd> </dd>
    446 <dt>description</dt>
    447 <dd>the exception description. </dd>
    448 
    449 <dd>  </dd>
    450 </dl>
    451 </div>
    452   <footer class="magick-footer">
    453     <p><a href="../support.html">Donate</a> 
    454      <a href="../sitemap.html">Sitemap</a> 
    455     <a href="../links.html">Related</a> 
    456     <a href="../architecture.html">Architecture</a>
    457 </p>
    458     <p><a href="exception.html#">Back to top</a> 
    459     <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x89AB63D48277377A">Public Key</a> 
    460     <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
    461         <p><small>  1999-2016 ImageMagick Studio LLC</small></p>
    462   </footer>
    463 </div><!-- /.container -->
    464 
    465   <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    466   <script src="../js/magick.html"></script>
    467 </div>
    468 </body>
    469 </html>
    470