Browse Source

Simplify exception when an encoder is not found

pull/870/head
Jason Nelson 7 years ago
parent
commit
27adde1c9c
  1. 6
      src/ImageSharp/ImageExtensions.cs
  2. 11
      src/ImageSharp/Memory/RowInterval.cs

6
src/ImageSharp/ImageExtensions.cs

@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp
if (format is null) if (format is null)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine($"Can't find a format that is associated with the file extension '{ext}'. Registered formats with there extensions include:"); sb.AppendLine($"No encoder was found for extension '{ext}'. Registered encoders include:");
foreach (IImageFormat fmt in source.GetConfiguration().ImageFormats) foreach (IImageFormat fmt in source.GetConfiguration().ImageFormats)
{ {
sb.AppendLine($" - {fmt.Name} : {string.Join(", ", fmt.FileExtensions)}"); sb.AppendLine($" - {fmt.Name} : {string.Join(", ", fmt.FileExtensions)}");
@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp
if (encoder is null) if (encoder is null)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine($"Can't find encoder for file extension '{ext}' using image format '{format.Name}'. Registered encoders include:"); sb.AppendLine($"No encoder was found for extension '{ext}' using image format '{format.Name}'. Registered encoders include:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> enc in source.GetConfiguration().ImageFormatsManager.ImageEncoders) foreach (KeyValuePair<IImageFormat, IImageEncoder> enc in source.GetConfiguration().ImageFormatsManager.ImageEncoders)
{ {
sb.AppendLine($" - {enc.Key} : {enc.Value.GetType().Name}"); sb.AppendLine($" - {enc.Key} : {enc.Value.GetType().Name}");
@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp
if (encoder is null) if (encoder is null)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine("Can't find encoder for provided mime type. Available encoded:"); sb.AppendLine("No encoder was found for the provided mime type. Registered encoders include:");
foreach (KeyValuePair<IImageFormat, IImageEncoder> val in source.GetConfiguration().ImageFormatsManager.ImageEncoders) foreach (KeyValuePair<IImageFormat, IImageEncoder> val in source.GetConfiguration().ImageFormatsManager.ImageEncoders)
{ {

11
src/ImageSharp/Memory/RowInterval.cs

@ -22,24 +22,21 @@ namespace SixLabors.ImageSharp.Memory
} }
/// <summary> /// <summary>
/// Gets the INCLUSIVE minimum /// Gets the INCLUSIVE minimum.
/// </summary> /// </summary>
public int Min { get; } public int Min { get; }
/// <summary> /// <summary>
/// Gets the EXCLUSIVE maximum /// Gets the EXCLUSIVE maximum.
/// </summary> /// </summary>
public int Max { get; } public int Max { get; }
/// <summary> /// <summary>
/// Gets the difference (<see cref="Max"/> - <see cref="Min"/>) /// Gets the difference (<see cref="Max"/> - <see cref="Min"/>).
/// </summary> /// </summary>
public int Height => this.Max - this.Min; public int Height => this.Max - this.Min;
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() public override string ToString() => $"RowInterval [{this.Min}->{this.Max}]";
{
return $"RowInterval [{this.Min}->{this.Max}[";
}
} }
} }
Loading…
Cancel
Save