Browse Source

Finishing error handling

Former-commit-id: c9850ccb110029d9f8b4d774afdabe620ec5bd6b
pull/17/head
James South 12 years ago
parent
commit
527ffc5e1b
  1. 9
      src/ImageProcessor/Processors/AutoRotate.cs
  2. 9
      src/ImageProcessor/Processors/BackgroundColor.cs
  3. 15
      src/ImageProcessor/Processors/Format.cs
  4. 15
      src/ImageProcessor/Processors/Quality.cs
  5. 2
      src/ImageProcessor/Processors/Watermark.cs

9
src/ImageProcessor/Processors/AutoRotate.cs

@ -11,8 +11,11 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Imaging; using ImageProcessor.Imaging;
/// <summary> /// <summary>
@ -93,7 +96,11 @@ namespace ImageProcessor.Processors
image = newImage; image = newImage;
} }
} }
catch catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
finally
{ {
if (newImage != null) if (newImage != null)
{ {

9
src/ImageProcessor/Processors/BackgroundColor.cs

@ -10,9 +10,12 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
/// <summary> /// <summary>
/// Changes the background color of an image. /// Changes the background color of an image.
/// </summary> /// </summary>
@ -68,7 +71,11 @@ namespace ImageProcessor.Processors
image.Dispose(); image.Dispose();
image = newImage; image = newImage;
} }
catch catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
finally
{ {
if (newImage != null) if (newImage != null)
{ {

15
src/ImageProcessor/Processors/Format.cs

@ -10,8 +10,11 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
using ImageProcessor.Imaging.Formats; using ImageProcessor.Imaging.Formats;
/// <summary> /// <summary>
@ -57,8 +60,16 @@ namespace ImageProcessor.Processors
/// </returns> /// </returns>
public Image ProcessImage(ImageFactory factory) public Image ProcessImage(ImageFactory factory)
{ {
ISupportedImageFormat format = this.DynamicParameter; try
factory.Format(format); {
ISupportedImageFormat format = this.DynamicParameter;
factory.Format(format);
}
catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
return factory.Image; return factory.Image;
} }
} }

15
src/ImageProcessor/Processors/Quality.cs

@ -11,8 +11,13 @@
namespace ImageProcessor.Processors namespace ImageProcessor.Processors
{ {
#region Using #region Using
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
#endregion #endregion
/// <summary> /// <summary>
@ -58,7 +63,15 @@ namespace ImageProcessor.Processors
/// </returns> /// </returns>
public Image ProcessImage(ImageFactory factory) public Image ProcessImage(ImageFactory factory)
{ {
factory.CurrentImageFormat.Quality = this.DynamicParameter; try
{
factory.CurrentImageFormat.Quality = this.DynamicParameter;
}
catch (Exception ex)
{
throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
}
return factory.Image; return factory.Image;
} }
} }

2
src/ImageProcessor/Processors/Watermark.cs

@ -180,4 +180,4 @@ namespace ImageProcessor.Processors
} }
} }
} }
} }
Loading…
Cancel
Save