Interface IUnresolvableDependencyClassifier

Namespace
Cratis.Arc.DependencyInjection
Assembly
Cratis.Arc.Core.dll

Defines a classifier that can recognize a non-nullable dependency which could not be resolved as invalid client input rather than a server-side misconfiguration.

public interface IUnresolvableDependencyClassifier
Extension Methods

Remarks

When a non-nullable dependency resolves to null it is, by default, a misconfiguration and surfaces as a server error (HTTP 500). Some absences are instead invalid client input — for example a Chronicle read model that does not exist for the command's (valid) event source id. An implementation recognizes such a case and produces an exception implementing IValidationFailure, so the pipeline surfaces it as a validation failure (HTTP 400). Implementations are discovered through IInstancesOf<T>; a dependency that no classifier recognizes keeps the default server-error behavior, so genuine misconfigurations are never masked as client input.

Methods

TryClassifyAsClientInput(ParameterInfo, IServiceProvider, out Exception?)

Tries to classify a non-nullable dependency that resolved to null as invalid client input.

bool TryClassifyAsClientInput(ParameterInfo parameter, IServiceProvider serviceProvider, out Exception? failure)

Parameters

parameter ParameterInfo

The ParameterInfo for the dependency that could not be resolved.

serviceProvider IServiceProvider

The command-scoped IServiceProvider the dependency was resolved from.

failure Exception

The exception describing the invalid client input, when classified; otherwise null.

Returns

bool

True when the unresolved dependency represents invalid client input; otherwise false.