Inheritance: System.Exception
Example #1
0
    protected void RaiseWarning(MagickException exception)
    {
      if (_WarningEvent == null)
        return;

      MagickWarningException warning = exception as MagickWarningException;
      if (warning != null)
        _WarningEvent.Invoke(this, new WarningEventArgs(warning));
    }
        public static MagickException Create(IntPtr exception)
        {
            if (exception == IntPtr.Zero)
            {
                return(null);
            }

            MagickException magickException = CreateException(exception);

            NativeMagickExceptionHelper.Dispose(exception);

            return(magickException);
        }
Example #3
0
        protected void RaiseWarning(MagickException exception)
        {
            if (_warningEvent == null)
            {
                return;
            }

            MagickWarningException warning = exception as MagickWarningException;

            if (warning != null)
            {
                _warningEvent.Invoke(this, new WarningEventArgs(warning));
            }
        }
        protected void CheckException(IntPtr exception, IntPtr result)
        {
            MagickException magickException = MagickExceptionHelper.Create(exception);

            if (MagickExceptionHelper.IsError(magickException))
            {
                if (result != IntPtr.Zero)
                {
                    Dispose(result);
                }
                throw magickException;
            }

            RaiseWarning(magickException);
        }
Example #5
0
        public static MagickException Check(IntPtr exception)
        {
            MagickException magickException = Create(exception);

            if (magickException == null)
            {
                return(null);
            }

            if (magickException is MagickErrorException)
            {
                throw magickException;
            }

            return(magickException);
        }
Example #6
0
        public static MagickException CreateException(IntPtr exception)
        {
            ExceptionSeverity severity    = (ExceptionSeverity)NativeMagickExceptionHelper.Severity(exception);
            string            message     = NativeMagickExceptionHelper.Message(exception);
            string            description = NativeMagickExceptionHelper.Description(exception);

            if (!string.IsNullOrEmpty(description))
            {
                message += " (" + description + ")";
            }

            List <MagickException> innerExceptions = CreateRelatedExceptions(exception);

            MagickException result = Create(severity, message);

            result.SetRelatedException(innerExceptions);

            return(result);
        }
 private static MagickException Create(ExceptionSeverity severity, string message, MagickException innerExceptions)
 {
   switch (severity)
   {
     case ExceptionSeverity.BlobWarning:
       return new MagickBlobWarningException(message, innerExceptions);
     case ExceptionSeverity.CacheWarning:
       return new MagickCacheWarningException(message, innerExceptions);
     case ExceptionSeverity.CoderWarning:
       return new MagickCoderWarningException(message, innerExceptions);
     case ExceptionSeverity.ConfigureWarning:
       return new MagickConfigureWarningException(message, innerExceptions);
     case ExceptionSeverity.CorruptImageWarning:
       return new MagickCorruptImageWarningException(message, innerExceptions);
     case ExceptionSeverity.DelegateWarning:
       return new MagickDelegateWarningException(message, innerExceptions);
     case ExceptionSeverity.DrawWarning:
       return new MagickDrawWarningException(message, innerExceptions);
     case ExceptionSeverity.FileOpenWarning:
       return new MagickFileOpenWarningException(message, innerExceptions);
     case ExceptionSeverity.ImageWarning:
       return new MagickImageWarningException(message, innerExceptions);
     case ExceptionSeverity.MissingDelegateWarning:
       return new MagickMissingDelegateWarningException(message, innerExceptions);
     case ExceptionSeverity.ModuleWarning:
       return new MagickModuleWarningException(message, innerExceptions);
     case ExceptionSeverity.OptionWarning:
       return new MagickOptionWarningException(message, innerExceptions);
     case ExceptionSeverity.PolicyWarning:
       return new MagickPolicyWarningException(message, innerExceptions);
     case ExceptionSeverity.RegistryWarning:
       return new MagickRegistryWarningException(message, innerExceptions);
     case ExceptionSeverity.ResourceLimitWarning:
       return new MagickResourceLimitWarningException(message, innerExceptions);
     case ExceptionSeverity.StreamWarning:
       return new MagickStreamWarningException(message, innerExceptions);
     case ExceptionSeverity.TypeWarning:
       return new MagickTypeWarningException(message, innerExceptions);
     case ExceptionSeverity.BlobError:
       return new MagickBlobErrorException(message, innerExceptions);
     case ExceptionSeverity.CacheError:
       return new MagickCacheErrorException(message, innerExceptions);
     case ExceptionSeverity.CoderError:
       return new MagickCoderErrorException(message, innerExceptions);
     case ExceptionSeverity.ConfigureError:
       return new MagickConfigureErrorException(message, innerExceptions);
     case ExceptionSeverity.CorruptImageError:
       return new MagickCorruptImageErrorException(message, innerExceptions);
     case ExceptionSeverity.DelegateError:
       return new MagickDelegateErrorException(message, innerExceptions);
     case ExceptionSeverity.DrawError:
       return new MagickDrawErrorException(message, innerExceptions);
     case ExceptionSeverity.FileOpenError:
       return new MagickFileOpenErrorException(message, innerExceptions);
     case ExceptionSeverity.ImageError:
       return new MagickImageErrorException(message, innerExceptions);
     case ExceptionSeverity.MissingDelegateError:
       return new MagickMissingDelegateErrorException(message, innerExceptions);
     case ExceptionSeverity.ModuleError:
       return new MagickModuleErrorException(message, innerExceptions);
     case ExceptionSeverity.OptionError:
       return new MagickOptionErrorException(message, innerExceptions);
     case ExceptionSeverity.PolicyError:
       return new MagickPolicyErrorException(message, innerExceptions);
     case ExceptionSeverity.RegistryError:
       return new MagickRegistryErrorException(message, innerExceptions);
     case ExceptionSeverity.ResourceLimitError:
       return new MagickResourceLimitErrorException(message, innerExceptions);
     case ExceptionSeverity.StreamError:
       return new MagickStreamErrorException(message, innerExceptions);
     case ExceptionSeverity.TypeError:
       return new MagickTypeErrorException(message, innerExceptions);
     default:
       if (severity < ExceptionSeverity.Error)
         return new MagickWarningException(message, innerExceptions);
       else
         return new MagickErrorException(message, innerExceptions);
   }
 }
    public static bool IsError(MagickException exception)
    {
      if (exception == null)
        return false;

      return exception is MagickErrorException;
    }
 /// <summary>
 /// Initializes a new instance of the MagickCorruptImageWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickCorruptImageWarningException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the MagickUndefinedErrorException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickUndefinedErrorException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MagickCoderErrorException"/> class.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickCoderErrorException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickCorruptImageWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickCorruptImageWarningException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickUndefinedWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickUndefinedWarningException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MagickRegistryErrorException"/> class.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickRegistryErrorException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the MagickConfigureWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickConfigureWarningException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickFileOpenErrorException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickFileOpenErrorException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MagickMissingDelegateWarningException"/> class.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickMissingDelegateWarningException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
Example #18
0
        protected void CheckException(IntPtr exception)
        {
            MagickException magickException = MagickExceptionHelper.Check(exception);

            RaiseWarning(magickException);
        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the MagickMissingDelegateWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickMissingDelegateWarningException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickFileOpenErrorException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickFileOpenErrorException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickResourceLimitErrorException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickResourceLimitErrorException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the MagickCacheErrorException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickCacheErrorException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickDrawWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickDrawWarningException(string message, MagickException innerException)
     : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickDelegateErrorException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickDelegateErrorException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MagickOptionWarningException"/> class.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickOptionWarningException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MagickResourceLimitErrorException"/> class.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickResourceLimitErrorException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
 /// <summary>
 /// Initializes a new instance of the MagickConfigureWarningException class with a specified error
 /// message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="innerException">The exception that is the cause of the current exception, or a
 /// null reference if no inner exception is specified.</param>
 public MagickConfigureWarningException(string message, MagickException innerException)
   : base(message, innerException)
 {
 }
        private static MagickException Create(ExceptionSeverity severity, string message, MagickException innerExceptions)
        {
            switch (severity)
            {
            case ExceptionSeverity.BlobWarning:
                return(new MagickBlobWarningException(message, innerExceptions));

            case ExceptionSeverity.CacheWarning:
                return(new MagickCacheWarningException(message, innerExceptions));

            case ExceptionSeverity.CoderWarning:
                return(new MagickCoderWarningException(message, innerExceptions));

            case ExceptionSeverity.ConfigureWarning:
                return(new MagickConfigureWarningException(message, innerExceptions));

            case ExceptionSeverity.CorruptImageWarning:
                return(new MagickCorruptImageWarningException(message, innerExceptions));

            case ExceptionSeverity.DelegateWarning:
                return(new MagickDelegateWarningException(message, innerExceptions));

            case ExceptionSeverity.DrawWarning:
                return(new MagickDrawWarningException(message, innerExceptions));

            case ExceptionSeverity.FileOpenWarning:
                return(new MagickFileOpenWarningException(message, innerExceptions));

            case ExceptionSeverity.ImageWarning:
                return(new MagickImageWarningException(message, innerExceptions));

            case ExceptionSeverity.MissingDelegateWarning:
                return(new MagickMissingDelegateWarningException(message, innerExceptions));

            case ExceptionSeverity.ModuleWarning:
                return(new MagickModuleWarningException(message, innerExceptions));

            case ExceptionSeverity.OptionWarning:
                return(new MagickOptionWarningException(message, innerExceptions));

            case ExceptionSeverity.PolicyWarning:
                return(new MagickPolicyWarningException(message, innerExceptions));

            case ExceptionSeverity.RegistryWarning:
                return(new MagickRegistryWarningException(message, innerExceptions));

            case ExceptionSeverity.ResourceLimitWarning:
                return(new MagickResourceLimitWarningException(message, innerExceptions));

            case ExceptionSeverity.StreamWarning:
                return(new MagickStreamWarningException(message, innerExceptions));

            case ExceptionSeverity.TypeWarning:
                return(new MagickTypeWarningException(message, innerExceptions));

            case ExceptionSeverity.BlobError:
                return(new MagickBlobErrorException(message, innerExceptions));

            case ExceptionSeverity.CacheError:
                return(new MagickCacheErrorException(message, innerExceptions));

            case ExceptionSeverity.CoderError:
                return(new MagickCoderErrorException(message, innerExceptions));

            case ExceptionSeverity.ConfigureError:
                return(new MagickConfigureErrorException(message, innerExceptions));

            case ExceptionSeverity.CorruptImageError:
                return(new MagickCorruptImageErrorException(message, innerExceptions));

            case ExceptionSeverity.DelegateError:
                return(new MagickDelegateErrorException(message, innerExceptions));

            case ExceptionSeverity.DrawError:
                return(new MagickDrawErrorException(message, innerExceptions));

            case ExceptionSeverity.FileOpenError:
                return(new MagickFileOpenErrorException(message, innerExceptions));

            case ExceptionSeverity.ImageError:
                return(new MagickImageErrorException(message, innerExceptions));

            case ExceptionSeverity.MissingDelegateError:
                return(new MagickMissingDelegateErrorException(message, innerExceptions));

            case ExceptionSeverity.ModuleError:
                return(new MagickModuleErrorException(message, innerExceptions));

            case ExceptionSeverity.OptionError:
                return(new MagickOptionErrorException(message, innerExceptions));

            case ExceptionSeverity.PolicyError:
                return(new MagickPolicyErrorException(message, innerExceptions));

            case ExceptionSeverity.RegistryError:
                return(new MagickRegistryErrorException(message, innerExceptions));

            case ExceptionSeverity.ResourceLimitError:
                return(new MagickResourceLimitErrorException(message, innerExceptions));

            case ExceptionSeverity.StreamError:
                return(new MagickStreamErrorException(message, innerExceptions));

            case ExceptionSeverity.TypeError:
                return(new MagickTypeErrorException(message, innerExceptions));

            default:
                if (severity < ExceptionSeverity.Error)
                {
                    return(new MagickWarningException(message, innerExceptions));
                }
                else
                {
                    return(new MagickErrorException(message, innerExceptions));
                }
            }
        }