1
// This may look like C code, but it is really -*- C++ -*-
3
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
5
// Implementation of Exception and derived classes
8
#define MAGICK_IMPLEMENTATION
10
#include "Magick++/Include.h"
17
#include "Magick++/Exception.h"
19
// Construct with message string
20
Magick::Exception::Exception( const std::string& what_ )
26
Magick::Exception::Exception( const Magick::Exception& original_ )
27
: _what(original_._what)
31
// Assignment operator
32
Magick::Exception& Magick::Exception::operator= (const Magick::Exception& original_ )
34
if(this != &original_)
36
this->_what = original_._what;
41
// Return message string
42
/*virtual*/ const char* Magick::Exception::what( ) const throw()
48
/*virtual*/ Magick::Exception::~Exception ( ) throw ()
56
Magick::Warning::Warning ( const std::string& what_ )
61
Magick::WarningUndefined::WarningUndefined ( const std::string& what_ )
66
Magick::WarningBlob::WarningBlob ( const std::string& what_ )
71
Magick::WarningCache::WarningCache ( const std::string& what_ )
76
Magick::WarningCoder::WarningCoder ( const std::string& what_ )
81
Magick::WarningConfigure::WarningConfigure ( const std::string& what_ )
86
Magick::WarningCorruptImage::WarningCorruptImage ( const std::string& what_ )
91
Magick::WarningDelegate::WarningDelegate ( const std::string& what_ )
96
Magick::WarningDraw::WarningDraw ( const std::string& what_ )
101
Magick::WarningFileOpen::WarningFileOpen ( const std::string& what_ )
106
Magick::WarningImage::WarningImage ( const std::string& what_ )
111
Magick::WarningMissingDelegate::WarningMissingDelegate ( const std::string& what_ )
116
Magick::WarningModule::WarningModule ( const std::string& what_ )
121
Magick::WarningMonitor::WarningMonitor ( const std::string& what_ )
126
Magick::WarningOption::WarningOption ( const std::string& what_ )
131
Magick::WarningRegistry::WarningRegistry ( const std::string& what_ )
136
Magick::WarningResourceLimit::WarningResourceLimit ( const std::string& what_ )
141
Magick::WarningStream::WarningStream ( const std::string& what_ )
146
Magick::WarningType::WarningType ( const std::string& what_ )
151
Magick::WarningXServer::WarningXServer ( const std::string& what_ )
160
Magick::Error::Error ( const std::string& what_ )
165
Magick::ErrorUndefined::ErrorUndefined ( const std::string& what_ )
170
Magick::ErrorBlob::ErrorBlob ( const std::string& what_ )
175
Magick::ErrorCache::ErrorCache ( const std::string& what_ )
180
Magick::ErrorCoder::ErrorCoder ( const std::string& what_ )
185
Magick::ErrorConfigure::ErrorConfigure ( const std::string& what_ )
190
Magick::ErrorCorruptImage::ErrorCorruptImage ( const std::string& what_ )
195
Magick::ErrorDelegate::ErrorDelegate ( const std::string& what_ )
200
Magick::ErrorDraw::ErrorDraw ( const std::string& what_ )
205
Magick::ErrorFileOpen::ErrorFileOpen ( const std::string& what_ )
210
Magick::ErrorImage::ErrorImage ( const std::string& what_ )
215
Magick::ErrorMissingDelegate::ErrorMissingDelegate ( const std::string& what_ )
220
Magick::ErrorModule::ErrorModule ( const std::string& what_ )
225
Magick::ErrorMonitor::ErrorMonitor ( const std::string& what_ )
230
Magick::ErrorOption::ErrorOption ( const std::string& what_ )
235
Magick::ErrorRegistry::ErrorRegistry ( const std::string& what_ )
240
Magick::ErrorResourceLimit::ErrorResourceLimit ( const std::string& what_ )
245
Magick::ErrorStream::ErrorStream ( const std::string& what_ )
250
Magick::ErrorType::ErrorType ( const std::string& what_ )
255
Magick::ErrorXServer::ErrorXServer ( const std::string& what_ )
260
// Format and throw exception
261
MagickDLLDecl void Magick::throwExceptionExplicit( const ExceptionType severity_,
263
const char* description_)
265
// Just return if there is no reported error
266
if ( severity_ == UndefinedException )
269
ExceptionInfo exception;
271
GetExceptionInfo( &exception );
272
ThrowException2( &exception, severity_, reason_, description_ );
273
throwException( exception );
276
// Throw C++ exception, resetting exception argument to default state
277
MagickDLLDecl void Magick::throwException( ExceptionInfo &exception_ )
279
// Just return if there is no reported error
280
if ( exception_.severity == UndefinedException )
283
// Format error message GraphicsMagick-style
284
std::string message = SetClientName(0);
285
if ( exception_.reason != 0 )
287
message += std::string(": ");
288
message += std::string(exception_.reason);
291
if ( exception_.description != 0 )
292
message += " (" + std::string(exception_.description) + ")";
294
if ( exception_.module != 0)
297
sprintf( line_str, "%lu", exception_.line);
298
message += " reported by " + std::string(exception_.module);
299
message += ":" + std::string(line_str);
300
if ((exception_.function != 0) && strcmp("unknown",exception_.function))
301
message += " (" + std::string(exception_.function) + ")";
304
ExceptionType severity = exception_.severity;
305
DestroyExceptionInfo( &exception_ );
306
GetExceptionInfo( &exception_ );
311
case ResourceLimitWarning :
312
throw WarningResourceLimit( message );
314
throw WarningType( message );
316
throw WarningOption( message );
317
case DelegateWarning :
318
throw WarningDelegate( message );
319
case MissingDelegateWarning :
320
throw WarningMissingDelegate( message );
321
case CorruptImageWarning :
322
throw WarningCorruptImage( message );
323
case FileOpenWarning :
324
throw WarningFileOpen( message );
326
throw WarningBlob ( message );
328
throw WarningStream ( message );
330
throw WarningCache ( message );
332
throw WarningCoder ( message );
334
throw WarningModule( message );
336
throw WarningDraw( message );
338
throw WarningImage( message );
339
case XServerWarning :
340
throw WarningXServer( message );
341
case MonitorWarning :
342
throw WarningMonitor( message );
343
case RegistryWarning :
344
throw WarningRegistry( message );
345
case ConfigureWarning :
346
throw WarningConfigure( message );
348
case ResourceLimitError :
349
case ResourceLimitFatalError :
350
throw ErrorResourceLimit( message );
352
case TypeFatalError :
353
throw ErrorType( message );
355
case OptionFatalError :
356
throw ErrorOption( message );
358
case DelegateFatalError :
359
throw ErrorDelegate( message );
360
case MissingDelegateError :
361
case MissingDelegateFatalError :
362
throw ErrorMissingDelegate( message );
363
case CorruptImageError :
364
case CorruptImageFatalError :
365
throw ErrorCorruptImage( message );
367
case FileOpenFatalError :
368
throw ErrorFileOpen( message );
370
case BlobFatalError :
371
throw ErrorBlob ( message );
373
case StreamFatalError :
374
throw ErrorStream ( message );
376
case CacheFatalError :
377
throw ErrorCache ( message );
379
case CoderFatalError :
380
throw ErrorCoder ( message );
382
case ModuleFatalError :
383
throw ErrorModule ( message );
385
case DrawFatalError :
386
throw ErrorDraw ( message );
388
case ImageFatalError :
389
throw ErrorImage ( message );
391
case XServerFatalError :
392
throw ErrorXServer ( message );
394
case MonitorFatalError :
395
throw ErrorMonitor ( message );
397
case RegistryFatalError :
398
throw ErrorRegistry ( message );
399
case ConfigureError :
400
case ConfigureFatalError :
401
throw ErrorConfigure ( message );
402
case UndefinedException :
404
throw ErrorUndefined( message );