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

9
src/ImageProcessor/Processors/BackgroundColor.cs

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

15
src/ImageProcessor/Processors/Format.cs

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

15
src/ImageProcessor/Processors/Quality.cs

@ -11,8 +11,13 @@
namespace ImageProcessor.Processors
{
#region Using
using System;
using System.Collections.Generic;
using System.Drawing;
using ImageProcessor.Core.Common.Exceptions;
#endregion
/// <summary>
@ -58,7 +63,15 @@ namespace ImageProcessor.Processors
/// </returns>
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;
}
}

2
src/ImageProcessor/Processors/Watermark.cs

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