Table of Contents

Class LimitExceededException

Namespace
Egami
Assembly
Egami.dll

Thrown when a SafetyLimits limit is exceeded.

public sealed class LimitExceededException : EgamiException, ISerializable
Inheritance
LimitExceededException
Implements
Inherited Members

Examples

EgamiContext strict = EgamiContext.Default with
{
    Limits = SafetyLimits.Default with { MaxPixels = 25_000_000, MaxTotalBytes = 256L * 1024 * 1024 },
};

try
{
    // Read the header first: cheap, and it rejects what you do not want before any pixel memory is used.
    RasterInfo info = Raster.Probe(upload, strict);
    if (info.Width > 8000 || info.Height > 8000)
    {
        throw new InvalidDataException("Too large.");
    }

    using Raster image = Raster.Load(upload, strict, new ReaderOptions { Recovery = RecoveryMode.Strict });
    Console.WriteLine($"{info.Format.Name} {image.Width} × {image.Height}");
}
catch (UnsupportedFormatException)
{
    Console.WriteLine("Not an image format we accept.");
}
catch (LimitExceededException e)
{
    Console.WriteLine($"Over the {e.LimitName} limit.");
}
catch (CorruptDataException e)
{
    Console.WriteLine($"Damaged at byte {e.Offset}.");
}

Constructors

LimitExceededException(string, long, long)

Initializes a new instance of the LimitExceededException class.

public LimitExceededException(string limitName, long allowed, long found)

Parameters

limitName string

The name of the limit, such as MaxPixels.

allowed long

The largest allowed value.

found long

The value found.

Properties

Allowed

Gets the largest allowed value.

public long Allowed { get; }

Property Value

long

Found

Gets the value found.

public long Found { get; }

Property Value

long

LimitName

Gets the name of the limit, matching a SafetyLimits property.

public string LimitName { get; }

Property Value

string