2
% Copyright (C) 2003 GraphicsMagick Group
3
% Copyright (C) 2002 ImageMagick Studio
4
% Copyright 1991-1999 E. I. du Pont de Nemours and Company
6
% This program is covered by multiple licenses, which are described in
7
% Copyright.txt. You should have received a copy of Copyright.txt with this
8
% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
% EEEEE RRRR RRRR OOO RRRR %
16
% EEE RRRR RRRR O O RRRR %
18
% EEEEE R R R R OOO R R %
21
% GraphicsMagick Exception Methods %
30
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
#include "magick/studio.h"
40
#include "magick/magick.h"
41
#include "magick/utility.h"
46
#if defined(__cplusplus) || defined(c_plusplus)
51
DefaultErrorHandler(const ExceptionType,const char *,const char *),
52
DefaultFatalErrorHandler(const ExceptionType,const char *,const char *),
53
DefaultWarningHandler(const ExceptionType,const char *,const char *);
55
#if defined(__cplusplus) || defined(c_plusplus)
63
error_handler = DefaultErrorHandler;
65
static FatalErrorHandler
66
fatal_error_handler = DefaultFatalErrorHandler;
69
warning_handler = DefaultWarningHandler;
72
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
% C a t c h E x c e p t i o n %
80
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82
% CatchException() returns if no exceptions is found otherwise it reports
83
% the exception as a warning, error, or fatal depending on the severity.
85
% The format of the CatchException method is:
87
% CatchException(const ExceptionInfo *exception)
89
% A description of each parameter follows:
91
% o exception: The exception info.
95
MagickExport void CatchException(const ExceptionInfo *exception)
97
assert(exception != (ExceptionInfo *) NULL);
98
assert(exception->signature == MagickSignature);
99
if (exception->severity == UndefinedException)
101
errno=exception->error_number; /* Shabby work-around for parameter limits */
102
if ((exception->severity >= WarningException) &&
103
(exception->severity < ErrorException))
105
MagickWarning2(exception->severity,exception->reason,
106
exception->description);
109
if ((exception->severity >= ErrorException) &&
110
(exception->severity < FatalErrorException))
112
MagickError2(exception->severity,exception->reason,exception->description);
115
if (exception->severity >= FatalErrorException)
117
MagickFatalError2(exception->severity,exception->reason,
118
exception->description);
124
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128
% C o p y E x c e p t i o n %
132
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134
% CopyException() copies exception data from one ExceptionInfo structure
137
% The format of the CopyException method is:
139
% void CopyException(ExceptionInfo *copy, const ExceptionInfo *original)
141
% A description of each parameter follows:
143
% o copy: The exception to copy to.
145
% o original: The exception to copy from.
148
MagickExport void CopyException(ExceptionInfo *copy, const ExceptionInfo *original)
150
assert(copy != (ExceptionInfo *) NULL);
151
assert(copy->signature == MagickSignature);
152
assert(original != (ExceptionInfo *) NULL);
153
assert(original->signature == MagickSignature);
154
copy->severity=original->severity;
155
MagickFreeMemory(copy->reason);
156
if (original->reason)
157
copy->reason=AcquireString(original->reason);
158
MagickFreeMemory(copy->description);
159
if (original->description)
160
copy->description=AcquireString(original->description);
161
copy->error_number=original->error_number;
162
MagickFreeMemory(copy->module);
163
if (original->module)
164
copy->module=AcquireString(original->module);
165
MagickFreeMemory(copy->function);
166
if (original->function)
167
copy->function=AcquireString(original->function);
168
copy->line=original->line;
173
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177
+ D e f a u l t E r r o r H a n d l e r %
181
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183
% Method DefaultErrorHandler displays an error reason.
185
% The format of the DefaultErrorHandler method is:
187
% void DefaultMagickError(const ExceptionType severity,
188
% const char *reason, const char *description)
190
% A description of each parameter follows:
192
% o severity: Specifies the numeric error category.
194
% o reason: Specifies the reason to display before terminating the
197
% o description: Specifies any description to the reason.
202
static const char *GetErrorMessageString(const int error_number)
207
message=strerror(error_number);
208
if (message == (const char *) NULL)
209
return("Error number is out of range");
213
static void DefaultErrorHandler(const ExceptionType severity,const char *reason,
214
const char *description)
216
if (reason == (char *) NULL)
219
(void) fprintf(stderr,"%.1024s: ",GetClientName());
220
if (strstr(reason,"%s") && description)
223
Reason contains printf specification. %s in reason string
224
is substituted with description.
226
(void) fprintf(stderr,reason,description);
230
(void) fprintf(stderr,"%.1024s",reason);
231
if (description != (char *) NULL)
232
(void) fprintf(stderr," (%.1024s)",description);
234
if ((severity != OptionError) && errno)
235
(void) fprintf(stderr," [%.1024s]",GetErrorMessageString(errno));
236
(void) fprintf(stderr,".\n");
240
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244
+ D e f a u l t F a t a l E r r o r H a n d l e r %
248
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250
% Method DefaultFatalErrorHandler displays an error reason and then terminates
253
% The format of the DefaultFatalErrorHandler method is:
255
% void DefaultMagickFatalError(const ExceptionType severity,
256
% const char *reason, const char *description)
258
% A description of each parameter follows:
260
% o severity: Specifies the numeric error category.
262
% o reason: Specifies the reason to display before terminating the
265
% o description: Specifies any description to the reason.
269
static void DefaultFatalErrorHandler(const ExceptionType severity,
270
const char *reason,const char *description)
272
if (reason == (char *) NULL)
274
(void) fprintf(stderr,"%.1024s: %.1024s",GetClientName(),reason);
275
if (description != (char *) NULL)
276
(void) fprintf(stderr," (%.1024s)",description);
277
if ((severity != OptionError) && errno)
278
(void) fprintf(stderr," [%.1024s]",GetErrorMessageString(errno));
279
(void) fprintf(stderr,".\n");
285
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289
+ D e f a u l t W a r n i n g H a n d l e r %
293
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295
% Method DefaultWarningHandler displays a warning reason.
297
% The format of the DefaultWarningHandler method is:
299
% void DefaultWarningHandler(const ExceptionType warning,
300
% const char *reason,const char *description)
302
% A description of each parameter follows:
304
% o warning: Specifies the numeric warning category.
306
% o reason: Specifies the reason to display before terminating the
309
% o description: Specifies any description to the reason.
313
static void DefaultWarningHandler(const ExceptionType severity,
314
const char *reason,const char *description)
316
if (reason == (char *) NULL)
318
(void) fprintf(stderr,"%.1024s: %.1024s",GetClientName(),reason);
319
if (description != (char *) NULL)
320
(void) fprintf(stderr," (%.1024s)",description);
321
if ((severity != OptionWarning) && errno)
322
(void) fprintf(stderr," [%.1024s]",GetErrorMessageString(errno));
323
(void) fprintf(stderr,".\n");
327
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331
% D e s t r o y E x c e p t i o n I n f o %
335
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337
% DestroyExceptionInfo() deallocates memory associated with exception.
339
% The format of the DestroyExceptionInfo method is:
341
% void DestroyExceptionInfo(ExceptionInfo *exception)
343
% A description of each parameter follows:
345
% o exception: The exception info.
349
MagickExport void DestroyExceptionInfo(ExceptionInfo *exception)
351
assert(exception != (ExceptionInfo *) NULL);
352
assert(exception->signature == MagickSignature);
353
exception->severity=UndefinedException;
354
MagickFreeMemory(exception->reason);
355
MagickFreeMemory(exception->description);
356
exception->error_number=0;
357
MagickFreeMemory(exception->module);
358
MagickFreeMemory(exception->function);
360
exception->signature=0UL;
364
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368
% G e t E x c e p t i o n I n f o %
372
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
374
% GetExceptionInfo() initializes an exception to default values.
376
% The format of the GetExceptionInfo method is:
378
% GetExceptionInfo(ExceptionInfo *exception)
380
% A description of each parameter follows:
382
% o exception: The exception info.
386
MagickExport void GetExceptionInfo(ExceptionInfo *exception)
388
assert(exception != (ExceptionInfo *) NULL);
389
exception->severity=UndefinedException;
391
exception->description=0;
392
exception->error_number=0;
394
exception->function=0;
396
exception->signature=MagickSignature;
400
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404
% G e t L o c a l e E x c e p t i o n M e s s a g e %
408
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410
% GetLocaleExceptionMessage() converts a enumerated exception severity and tag
411
% to a message in the current locale.
413
% The format of the GetLocaleExceptionMessage method is:
415
% const char *GetLocaleExceptionMessage(const ExceptionType severity,
418
% A description of each parameter follows:
420
% o severity: the severity of the exception.
422
% o tag: the message tag.
428
static const char *ExceptionSeverityToTag(const ExceptionType severity)
432
case UndefinedException: return("Unknown/Error/");
433
case ResourceLimitWarning: return("Resource/Limit/Warning/");
434
case TypeWarning: return("Type/Warning/");
435
case OptionWarning: return("Option/Warning/");
436
case DelegateWarning: return("Delegate/Warning/");
437
case MissingDelegateWarning: return("Missing/Delegate/Warning/");
438
case CorruptImageWarning: return("Corrupt/Image/Warning/");
439
case FileOpenWarning: return("File/Open/Warning/");
440
case BlobWarning: return("Blob/Warning/");
441
case StreamWarning: return("Stream/Warning/");
442
case CacheWarning: return("Cache/Warning/");
443
case CoderWarning: return("Coder/Warning/");
444
case ModuleWarning: return("Module/Warning/");
445
case DrawWarning: return("Draw/Warning/");
446
case ImageWarning: return("Image/Warning/");
447
case WandWarning: return("Wand/Warning/");
448
case XServerWarning: return("XServer/Warning/");
449
case MonitorWarning: return("Monitor/Warning/");
450
case RegistryWarning: return("Registry/Warning/");
451
case ConfigureWarning: return("Configure/Warning/");
452
case ResourceLimitError: return("Resource/Limit/Error/");
453
case TypeError: return("Type/Error/");
454
case OptionError: return("Option/Error/");
455
case DelegateError: return("Delegate/Error/");
456
case MissingDelegateError: return("Missing/Delegate/Error/");
457
case CorruptImageError: return("Corrupt/Image/Error/");
458
case FileOpenError: return("File/Open/Error/");
459
case BlobError: return("Blob/Error/");
460
case StreamError: return("Stream/Error/");
461
case CacheError: return("Cache/Error/");
462
case CoderError: return("Coder/Error/");
463
case ModuleError: return("Module/Error/");
464
case DrawError: return("Draw/Error/");
465
case ImageError: return("Image/Error/");
466
case WandError: return("Wand/Error/");
467
case XServerError: return("XServer/Error/");
468
case MonitorError: return("Monitor/Error/");
469
case RegistryError: return("Registry/Error/");
470
case ConfigureError: return("Configure/Error/");
471
case ResourceLimitFatalError: return("Resource/Limit/FatalError/");
472
case TypeFatalError: return("Type/FatalError/");
473
case OptionFatalError: return("Option/FatalError/");
474
case DelegateFatalError: return("Delegate/FatalError/");
475
case MissingDelegateFatalError: return("Missing/Delegate/FatalError/");
476
case CorruptImageFatalError: return("Corrupt/Image/FatalError/");
477
case FileOpenFatalError: return("File/Open/FatalError/");
478
case BlobFatalError: return("Blob/FatalError/");
479
case StreamFatalError: return("Stream/FatalError/");
480
case CacheFatalError: return("Cache/FatalError/");
481
case CoderFatalError: return("Coder/FatalError/");
482
case ModuleFatalError: return("Module/FatalError/");
483
case DrawFatalError: return("Draw/FatalError/");
484
case ImageFatalError: return("Image/FatalError/");
485
case WandFatalError: return("Wand/FatalError/");
486
case XServerFatalError: return("XServer/FatalError/");
487
case MonitorFatalError: return("Monitor/FatalError/");
488
case RegistryFatalError: return("Registry/FatalError/");
489
case ConfigureFatalError: return("Configure/FatalError/");
495
MagickExport const char *GetLocaleExceptionMessage(const ExceptionType severity,
499
message[MaxTextExtent];
504
/* protect against NULL lookups */
505
if (tag != (char *) NULL)
507
/* This is a hack that depends on the fact that tag can never have spaces in
508
them. If a space is found then it means we are being asked to translate a
509
message that has already been translated. A big waste of time. The reason
510
this happens is that messages are translated at the point of an exception
511
and then again when the exception is caught and processed via the default
512
error and warning handlers
514
if (strrchr(tag, ' '))
516
FormatString(message,"%.1024s%.1024s",ExceptionSeverityToTag(severity),tag);
517
locale_message=GetLocaleMessage(message);
518
if (locale_message == message)
520
return(locale_message);
526
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530
% M a g i c k E r r o r %
534
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536
% Method MagickError calls the error handler methods with an error reason.
538
% The format of the MagickError method is:
540
% void MagickError(const ExceptionType error,const char *reason,
541
% const char *description)
543
% A description of each parameter follows:
545
% o exception: Specifies the numeric error category.
547
% o reason: Specifies the reason to display before terminating the
550
% o description: Specifies any description to the reason.
554
#if defined(MagickError)
555
MagickExport void _MagickError(const ExceptionType error,const char *reason,
556
const char *description)
558
if (error_handler != (ErrorHandler) NULL)
559
(*error_handler)(error,GetLocaleExceptionMessage(error,reason),
560
GetLocaleExceptionMessage(error,description));
564
MagickExport void MagickError(const ExceptionType error,const char *reason,
565
const char *description)
567
if (error_handler != (ErrorHandler) NULL)
568
(*error_handler)(error,GetLocaleExceptionMessage(error,reason),
569
GetLocaleExceptionMessage(error,description));
573
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
577
% M a g i c k F a t a l E r r o r %
581
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
583
% MagickFatalError() calls the fatal error handler methods with an error
586
% The format of the MagickError method is:
588
% void MagickFatalError(const ExceptionType error,const char *reason,
589
% const char *description)
591
% A description of each parameter follows:
593
% o exception: Specifies the numeric error category.
595
% o reason: Specifies the reason to display before terminating the
598
% o description: Specifies any description to the reason.
602
#if defined(MagickFatalError)
603
MagickExport void _MagickFatalError(const ExceptionType error,const char *reason,
604
const char *description)
606
if (fatal_error_handler != (ErrorHandler) NULL)
607
(*fatal_error_handler)(error,GetLocaleExceptionMessage(error,reason),
608
GetLocaleExceptionMessage(error,description));
612
#undef MagickFatalError
613
MagickExport void MagickFatalError(const ExceptionType error,const char *reason,
614
const char *description)
616
if (fatal_error_handler != (ErrorHandler) NULL)
617
(*fatal_error_handler)(error,GetLocaleExceptionMessage(error,reason),
618
GetLocaleExceptionMessage(error,description));
623
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627
% M a g i c k W a r n i n g %
631
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
633
% Method MagickWarning calls the warning handler methods with a warning
636
% The format of the MagickWarning method is:
638
% void MagickWarning(const ExceptionType warning,const char *reason,
639
% const char *description)
641
% A description of each parameter follows:
643
% o warning: The warning severity.
645
% o reason: Define the reason for the warning.
647
% o description: Describe the warning.
651
#if defined(MagickWarning)
652
MagickExport void _MagickWarning(const ExceptionType warning,const char *reason,
653
const char *description)
655
if (warning_handler != (WarningHandler) NULL)
656
(*warning_handler)(warning,GetLocaleExceptionMessage(warning,reason),
657
GetLocaleExceptionMessage(warning,description));
661
MagickExport void MagickWarning(const ExceptionType warning,const char *reason,
662
const char *description)
664
if (warning_handler != (WarningHandler) NULL)
665
(*warning_handler)(warning,GetLocaleExceptionMessage(warning,reason),
666
GetLocaleExceptionMessage(warning,description));
670
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
674
% S e t E r r o r H a n d l e r %
678
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
680
% SetErrorHandler() sets the error handler to the specified method
681
% and returns the previous error handler.
683
% The format of the SetErrorHandler method is:
685
% ErrorHandler SetErrorHandler(ErrorHandler handler)
687
% A description of each parameter follows:
689
% o handler: The method to handle errors.
693
MagickExport ErrorHandler SetErrorHandler(ErrorHandler handler)
698
previous_handler=error_handler;
699
error_handler=handler;
700
return(previous_handler);
704
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
708
% S e t E x c e p t i o n I n f o %
712
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
714
% SetExceptionInfo() set the exception severity.
716
% The format of the SetExceptionInfo method is:
718
% SetExceptionInfo(ExceptionInfo *exception,ExceptionType severity)
720
% A description of each parameter follows:
722
% o exception: The exception info.
724
% o severity: The exception severity.
728
MagickExport void SetExceptionInfo(ExceptionInfo *exception,
729
ExceptionType severity)
731
assert(exception != (ExceptionInfo *) NULL);
732
exception->severity=severity;
737
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741
% S e t F a t a l E r r o r H a n d l e r %
745
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
747
% SetFatalErrorHandler() sets the fatal error handler to the specified method
748
% and returns the previous fatal error handler.
750
% The format of the SetErrorHandler method is:
752
% ErrorHandler SetErrorHandler(ErrorHandler handler)
754
% A description of each parameter follows:
756
% o handler: The method to handle errors.
760
MagickExport FatalErrorHandler SetFatalErrorHandler(FatalErrorHandler handler)
765
previous_handler=fatal_error_handler;
766
fatal_error_handler=handler;
767
return(previous_handler);
771
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
775
% S e t W a r n i n g H a n d l e r %
779
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
781
% SetWarningHandler() sets the warning handler to the specified method
782
% and returns the previous warning handler.
784
% The format of the SetWarningHandler method is:
786
% ErrorHandler SetWarningHandler(ErrorHandler handler)
788
% A description of each parameter follows:
790
% o handler: The method to handle warnings.
794
MagickExport WarningHandler SetWarningHandler(WarningHandler handler)
799
previous_handler=warning_handler;
800
warning_handler=handler;
801
return(previous_handler);
805
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
809
% T h r o w E x c e p t i o n %
813
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
815
% ThrowException() throws an exception with the specified severity code,
816
% reason, and optional description.
818
% The format of the ThrowException method is:
820
% void ThrowException(ExceptionInfo *exception,
821
% const ExceptionType severity,const char *reason,
822
% const char *description)
824
% A description of each parameter follows:
826
% o exception: The exception.
828
% o severity: The severity of the exception.
830
% o reason: The reason of the exception.
832
% o description: The exception description.
836
#undef ThrowException
837
MagickExport void ThrowException(ExceptionInfo *exception,
838
const ExceptionType severity,const char *reason,const char *description)
840
assert(exception != (ExceptionInfo *) NULL);
841
assert(exception->signature == MagickSignature);
842
exception->severity=(ExceptionType) severity;
843
MagickFreeMemory(exception->reason);
846
AcquireString(GetLocaleExceptionMessage(severity,reason));
847
MagickFreeMemory(exception->description);
849
exception->description=
850
AcquireString(GetLocaleExceptionMessage(severity,description));
851
exception->error_number=errno;
852
MagickFreeMemory(exception->module);
853
MagickFreeMemory(exception->function);
855
exception->signature=0UL;
860
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
864
% T h r o w L o g g e d E x c e p t i o n %
868
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
870
% ThrowLoggedException() throws an exception with the specified severity code,
871
% reason, optional description, source filename, function name, and line
872
% number. If logging is enabled, the exception is also logged.
874
% The format of the ThrowLoggedException method is:
876
% void ThrowLoggedException(ExceptionInfo *exception,
877
% const ExceptionType severity,const char *reason,
878
% const char *description,const char *module,
879
% const char *function,const unsigned long line
881
% A description of each parameter follows:
883
% o exception: The exception.
885
% o severity: The severity of the exception.
887
% o reason: The reason of the exception.
889
% o description: The exception description.
891
% o filename: The source module filename.
893
% o function: The function name.
895
% o line: The line number of the source module.
899
MagickExport void ThrowLoggedException(ExceptionInfo *exception,
900
const ExceptionType severity,const char *reason,const char *description,
901
const char *module,const char *function,const unsigned long line)
903
assert(exception != (ExceptionInfo *) NULL);
904
assert(exception->signature == MagickSignature);
905
exception->severity=(ExceptionType) severity;
906
MagickFreeMemory(exception->reason);
909
AcquireString(GetLocaleExceptionMessage(severity,reason));
910
MagickFreeMemory(exception->description);
912
exception->description=
913
AcquireString(GetLocaleExceptionMessage(severity,description));
914
exception->error_number=errno;
915
MagickFreeMemory(exception->module);
917
exception->module=AcquireString(module);
918
MagickFreeMemory(exception->function);
920
exception->function=AcquireString(function);
921
exception->line=line;
922
if (exception->reason)
924
if (exception->description)
925
LogMagickEvent(severity,module,function,line,"%.1024s (%.1024s)",
926
exception->reason,exception->description );
928
LogMagickEvent(severity,module,function,line,"%.1024s",
933
LogMagickEvent(severity,module,function,line,
934
"exception contains no reason!");