Class ReadModelUnresolvableDependencyClassifier
- Namespace
- Cratis.Arc.Queries
- Assembly
- Cratis.Arc.Core.dll
Represents an IUnresolvableDependencyClassifier that recognizes a non-nullable read model dependency which does not exist for the command's resolved key as invalid client input rather than a server fault.
[Singleton]
public class ReadModelUnresolvableDependencyClassifier : IUnresolvableDependencyClassifier
- Inheritance
-
ReadModelUnresolvableDependencyClassifier
- Implements
- Inherited Members
- Extension Methods
Remarks
The classifier only runs when a non-nullable dependency resolved to null. For a read model resolved through an ICanResolveReadModelForCommand, a null result can only mean the entity does not exist for a usable key: a command carrying no usable key throws UnableToResolveReadModelFromCommandContext inside the resolver before this point. It therefore classifies a registered read model dependency with a usable resolved key as a ReadModelDoesNotExistForCommand (HTTP 400). Any dependency that is not a registered read model, or where no usable key is available, is left for the default server-error behavior so misconfigurations are not masked.
Constructors
ReadModelUnresolvableDependencyClassifier()
public ReadModelUnresolvableDependencyClassifier()
Methods
TryClassifyAsClientInput(ParameterInfo, IServiceProvider, out Exception?)
Tries to classify a non-nullable dependency that resolved to null as invalid client input.
public bool TryClassifyAsClientInput(ParameterInfo parameter, IServiceProvider serviceProvider, out Exception? failure)
Parameters
parameterParameterInfoThe ParameterInfo for the dependency that could not be resolved.
serviceProviderIServiceProviderThe command-scoped IServiceProvider the dependency was resolved from.
failureExceptionThe exception describing the invalid client input, when classified; otherwise null.
Returns
- bool
True when the unresolved dependency represents invalid client input; otherwise false.