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 private methods. 17 */ 18 #ifndef MAGICKCORE_EXCEPTION_PRIVATE_H 19 #define MAGICKCORE_EXCEPTION_PRIVATE_H 20 21 #include "MagickCore/log.h" 22 #include "MagickCore/magick.h" 23 #include "MagickCore/string_.h" 24 25 #if defined(__cplusplus) || defined(c_plusplus) 26 extern "C" { 27 #endif 28 29 #define ThrowBinaryException(severity,tag,context) \ 30 { \ 31 if (image != (Image *) NULL) \ 32 (void) ThrowMagickException(exception,GetMagickModule(),severity, \ 33 tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \ 34 return(MagickFalse); \ 35 } 36 #define ThrowFatalException(severity,tag) \ 37 { \ 38 char \ 39 *fatal_message; \ 40 \ 41 ExceptionInfo \ 42 *fatal_exception; \ 43 \ 44 fatal_exception=AcquireExceptionInfo(); \ 45 fatal_message=GetExceptionMessage(errno); \ 46 (void) ThrowMagickException(fatal_exception,GetMagickModule(),severity, \ 47 tag == (const char *) NULL ? "unknown" : tag,"`%s'",fatal_message); \ 48 fatal_message=DestroyString(fatal_message); \ 49 CatchException(fatal_exception); \ 50 (void) DestroyExceptionInfo(fatal_exception); \ 51 MagickCoreTerminus(); \ 52 _exit((int) (severity-FatalErrorException)+1); \ 53 } 54 #define ThrowFileException(exception,severity,tag,context) \ 55 { \ 56 char \ 57 *file_message; \ 58 \ 59 file_message=GetExceptionMessage(errno); \ 60 (void) ThrowMagickException(exception,GetMagickModule(),severity, \ 61 tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context, \ 62 file_message); \ 63 file_message=DestroyString(file_message); \ 64 } 65 #define ThrowImageException(severity,tag) \ 66 { \ 67 (void) ThrowMagickException(exception,GetMagickModule(),severity, \ 68 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ 69 return((Image *) NULL); \ 70 } 71 #define ThrowReaderException(severity,tag) \ 72 { \ 73 (void) ThrowMagickException(exception,GetMagickModule(),severity, \ 74 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image_info->filename); \ 75 if ((image) != (Image *) NULL) \ 76 { \ 77 (void) CloseBlob(image); \ 78 image=DestroyImageList(image); \ 79 } \ 80 return((Image *) NULL); \ 81 } 82 #define ThrowWriterException(severity,tag) \ 83 { \ 84 (void) ThrowMagickException(exception,GetMagickModule(),severity, \ 85 tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ 86 if (image_info->adjoin != MagickFalse) \ 87 while (image->previous != (Image *) NULL) \ 88 image=image->previous; \ 89 (void) CloseBlob(image); \ 90 return(MagickFalse); \ 91 } 92 93 extern MagickPrivate void 94 InitializeExceptionInfo(ExceptionInfo *); 95 96 #if defined(__cplusplus) || defined(c_plusplus) 97 } 98 #endif 99 100 #endif 101