cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 2 | Copyright 1999-2011 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 private methods. |
| 17 | */ |
| 18 | #ifndef _MAGICKCORE_EXCEPTION_PRIVATE_H |
| 19 | #define _MAGICKCORE_EXCEPTION_PRIVATE_H |
| 20 | |
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | #include "magick/log.h" |
cristy | d7ecaca | 2011-01-24 14:14:53 +0000 | [diff] [blame] | 26 | #include "magick/string_.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 27 | |
| 28 | #define ThrowBinaryException(severity,tag,context) \ |
| 29 | { \ |
| 30 | if (image != (Image *) NULL) \ |
| 31 | (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \ |
| 32 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \ |
| 33 | return(MagickFalse); \ |
| 34 | } |
| 35 | #define ThrowFatalException(severity,tag) \ |
| 36 | { \ |
cristy | 5bf97b5 | 2011-01-24 13:21:15 +0000 | [diff] [blame] | 37 | char \ |
| 38 | *message; \ |
| 39 | \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 40 | ExceptionInfo \ |
| 41 | exception; \ |
| 42 | \ |
| 43 | GetExceptionInfo(&exception); \ |
cristy | 5bf97b5 | 2011-01-24 13:21:15 +0000 | [diff] [blame] | 44 | message=GetExceptionMessage(errno); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 45 | (void) ThrowMagickException(&exception,GetMagickModule(),severity, \ |
cristy | 5bf97b5 | 2011-01-24 13:21:15 +0000 | [diff] [blame] | 46 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",message); \ |
| 47 | message=DestroyString(message); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 48 | CatchException(&exception); \ |
| 49 | (void) DestroyExceptionInfo(&exception); \ |
| 50 | _exit(1); \ |
| 51 | } |
| 52 | #define ThrowFileException(exception,severity,tag,context) \ |
| 53 | { \ |
cristy | 5bf97b5 | 2011-01-24 13:21:15 +0000 | [diff] [blame] | 54 | char \ |
| 55 | *message; \ |
| 56 | \ |
| 57 | message=GetExceptionMessage(errno); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 58 | (void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
cristy | 5bf97b5 | 2011-01-24 13:21:15 +0000 | [diff] [blame] | 59 | tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context,message); \ |
| 60 | message=DestroyString(message); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 61 | } |
| 62 | #define ThrowImageException(severity,tag) \ |
| 63 | { \ |
| 64 | (void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
| 65 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ |
| 66 | return((Image *) NULL); \ |
| 67 | } |
| 68 | #define ThrowReaderException(severity,tag) \ |
| 69 | { \ |
| 70 | (void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
| 71 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",image_info->filename); \ |
| 72 | if ((image) != (Image *) NULL) \ |
| 73 | { \ |
| 74 | (void) CloseBlob(image); \ |
| 75 | image=DestroyImageList(image); \ |
| 76 | } \ |
| 77 | return((Image *) NULL); \ |
| 78 | } |
| 79 | #define ThrowWriterException(severity,tag) \ |
| 80 | { \ |
| 81 | (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \ |
| 82 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ |
| 83 | if (image_info->adjoin != MagickFalse) \ |
| 84 | while (image->previous != (Image *) NULL) \ |
| 85 | image=image->previous; \ |
| 86 | (void) CloseBlob(image); \ |
| 87 | return(MagickFalse); \ |
| 88 | } |
| 89 | |
| 90 | #if defined(__cplusplus) || defined(c_plusplus) |
| 91 | } |
| 92 | #endif |
| 93 | |
| 94 | #endif |