cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
cristy | 16af1cb | 2009-12-11 21:38:29 +0000 | [diff] [blame] | 2 | Copyright 1999-2010 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" |
| 26 | |
| 27 | #define ThrowBinaryException(severity,tag,context) \ |
| 28 | { \ |
| 29 | if (image != (Image *) NULL) \ |
| 30 | (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \ |
| 31 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \ |
| 32 | return(MagickFalse); \ |
| 33 | } |
| 34 | #define ThrowFatalException(severity,tag) \ |
| 35 | { \ |
| 36 | ExceptionInfo \ |
| 37 | exception; \ |
| 38 | \ |
| 39 | GetExceptionInfo(&exception); \ |
| 40 | (void) ThrowMagickException(&exception,GetMagickModule(),severity, \ |
cristy | 5c50262 | 2009-12-22 02:43:02 +0000 | [diff] [blame] | 41 | tag == (const char *) NULL ? "unknown" : tag,"`%s'", \ |
| 42 | GetExceptionMessage(errno)); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 43 | CatchException(&exception); \ |
| 44 | (void) DestroyExceptionInfo(&exception); \ |
| 45 | _exit(1); \ |
| 46 | } |
| 47 | #define ThrowFileException(exception,severity,tag,context) \ |
| 48 | { \ |
| 49 | (void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
| 50 | tag == (const char *) NULL ? "unknown" : tag,"`%s': %s",context, \ |
cristy | 5c50262 | 2009-12-22 02:43:02 +0000 | [diff] [blame] | 51 | GetExceptionMessage(errno)); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 52 | } |
| 53 | #define ThrowImageException(severity,tag) \ |
| 54 | { \ |
| 55 | (void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
| 56 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ |
| 57 | return((Image *) NULL); \ |
| 58 | } |
| 59 | #define ThrowReaderException(severity,tag) \ |
| 60 | { \ |
| 61 | (void) ThrowMagickException(exception,GetMagickModule(),severity, \ |
| 62 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",image_info->filename); \ |
| 63 | if ((image) != (Image *) NULL) \ |
| 64 | { \ |
| 65 | (void) CloseBlob(image); \ |
| 66 | image=DestroyImageList(image); \ |
| 67 | } \ |
| 68 | return((Image *) NULL); \ |
| 69 | } |
| 70 | #define ThrowWriterException(severity,tag) \ |
| 71 | { \ |
| 72 | (void) ThrowMagickException(&image->exception,GetMagickModule(),severity, \ |
| 73 | tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ |
| 74 | if (image_info->adjoin != MagickFalse) \ |
| 75 | while (image->previous != (Image *) NULL) \ |
| 76 | image=image->previous; \ |
| 77 | (void) CloseBlob(image); \ |
| 78 | return(MagickFalse); \ |
| 79 | } |
| 80 | |
| 81 | #if defined(__cplusplus) || defined(c_plusplus) |
| 82 | } |
| 83 | #endif |
| 84 | |
| 85 | #endif |