Browse Source

Change ImageFormatException to InvalidImageContentException

pull/1574/head
Brian Popow 6 years ago
parent
commit
5a6659862a
  1. 14
      src/ImageSharp/Common/Exceptions/InvalidImageContentException.cs
  2. 4
      src/ImageSharp/Formats/Bmp/BmpDecoder.cs
  3. 4
      src/ImageSharp/Formats/Gif/GifDecoder.cs
  4. 4
      src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
  5. 4
      src/ImageSharp/Formats/Png/PngDecoder.cs
  6. 4
      src/ImageSharp/Formats/Tga/TgaDecoder.cs

14
src/ImageSharp/Common/Exceptions/InvalidImageContentException.cs

@ -1,6 +1,8 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
namespace SixLabors.ImageSharp namespace SixLabors.ImageSharp
{ {
/// <summary> /// <summary>
@ -18,5 +20,17 @@ namespace SixLabors.ImageSharp
: base(errorMessage) : base(errorMessage)
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="InvalidImageContentException"/> class with the name of the
/// parameter that causes this exception.
/// </summary>
/// <param name="errorMessage">The error message that explains the reason for this exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic)
/// if no inner exception is specified.</param>
public InvalidImageContentException(string errorMessage, Exception innerException)
: base(errorMessage, innerException)
{
}
} }
} }

4
src/ImageSharp/Formats/Bmp/BmpDecoder.cs

@ -43,9 +43,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
{ {
Size dims = decoder.Dimensions; Size dims = decoder.Dimensions;
// TODO: use InvalidImageContentException here, if we decide to define it throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}. This error can happen for very large RLE bitmaps, which are not supported.", ex);
// https://github.com/SixLabors/ImageSharp/issues/1110
throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}. This error can happen for very large RLE bitmaps, which are not supported.", ex);
} }
} }

4
src/ImageSharp/Formats/Gif/GifDecoder.cs

@ -38,9 +38,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
{ {
Size dims = decoder.Dimensions; Size dims = decoder.Dimensions;
// TODO: use InvalidImageContentException here, if we decide to define it throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
// https://github.com/SixLabors/ImageSharp/issues/1110
throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
} }
} }

4
src/ImageSharp/Formats/Jpeg/JpegDecoder.cs

@ -32,9 +32,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
{ {
(int w, int h) = (decoder.ImageWidth, decoder.ImageHeight); (int w, int h) = (decoder.ImageWidth, decoder.ImageHeight);
// TODO: use InvalidImageContentException here, if we decide to define it throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {w}x{h}.", ex);
// https://github.com/SixLabors/ImageSharp/issues/1110
throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {w}x{h}.", ex);
} }
} }

4
src/ImageSharp/Formats/Png/PngDecoder.cs

@ -54,9 +54,7 @@ namespace SixLabors.ImageSharp.Formats.Png
{ {
Size dims = decoder.Dimensions; Size dims = decoder.Dimensions;
// TODO: use InvalidImageContentException here, if we decide to define it throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
// https://github.com/SixLabors/ImageSharp/issues/1110
throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
} }
} }

4
src/ImageSharp/Formats/Tga/TgaDecoder.cs

@ -28,9 +28,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
{ {
Size dims = decoder.Dimensions; Size dims = decoder.Dimensions;
// TODO: use InvalidImageContentException here, if we decide to define it throw new InvalidImageContentException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
// https://github.com/SixLabors/ImageSharp/issues/1110
throw new ImageFormatException($"Can not decode image. Failed to allocate buffers for possibly degenerate dimensions: {dims.Width}x{dims.Height}.", ex);
} }
} }

Loading…
Cancel
Save