Skip to content

ContainerVerificationException

NexusLabs.Needlr

NexusLabs.Needlr

ContainerVerificationException Class

Exception thrown when Needlr container verification detects one or more registered issues that are configured to fail-fast at startup.

public sealed class ContainerVerificationException : System.Exception

Inheritance System.Object 🡒 System.Exception 🡒 ContainerVerificationException

Example

try
{
    var provider = services.BuildServiceProvider();
    provider.VerifyContainer();
}
catch (ContainerVerificationException ex)
{
    foreach (var issue in ex.Issues)
    {
        Console.Error.WriteLine($"[{issue.Type}] {issue.Message}");
    }
    throw;
}

Remarks

Container verification is triggered by calling VerifyContainer() (or the equivalent extension) after building the service provider. Each VerificationIssue in Issues describes one problem — for example, a missing required dependency or a misconfigured lifetime.

Only issues whose configured severity is set to throw will produce this exception. Issues configured to warn are reported through the logging pipeline instead.

Constructors

ContainerVerificationException(IReadOnlyList<VerificationIssue>) Constructor

Creates a new container verification exception.

public ContainerVerificationException(System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.VerificationIssue> issues);

Parameters

issues System.Collections.Generic.IReadOnlyList<VerificationIssue>

The verification issues that caused the exception.

Properties

ContainerVerificationException.Issues Property

Gets the verification issues that caused this exception.

public System.Collections.Generic.IReadOnlyList<NexusLabs.Needlr.VerificationIssue> Issues { get; }

Property Value

System.Collections.Generic.IReadOnlyList<VerificationIssue>