Skip to content

2.0.0-preview.1

Pre-release
Pre-release

Choose a tag to compare

@hlib-zinchenko hlib-zinchenko released this 27 Nov 10:01
· 2 commits to main since this release

Breaking changes

  • .NET 11 only, on Hlibz.Results 3.0. .NET 10 apps stay on 1.x.
  • An invalid use case fails with the ambient ValidationFailed. UseCaseValidationOptions.FailureStatus and FailureMessage are gone: the error carries its own status, and the HTTP layer picks 400 or 422.
  • A filter's own failure must be an ambient error (Forbidden, Unauthorized or Unavailable) when the handler declares its errors. Any other error from a filter throws for such a handler.

Features

  • Handlers declare their errors. IUseCaseHandler<TUseCase, TResult, TError> returns Result<TResult, TError>, where TError is a union of error types. Clients switch over the errors exhaustively, and documentation lists each one with its data.

    public union DeleteCityError(CityNotFound, CityInUse);
    
    public interface IDeleteCityCommandHandler : IUseCaseHandler<DeleteCityCommand, Unit, DeleteCityError>;
  • UseCaseDescriptor.ErrorSetType names a use case's error set, so IUseCaseCatalog tells adapters which errors each use case fails with. Hlibz.OpenApi.UseCases uses it for OpenAPI documents; an app can use it for MCP tools.

  • The samples are plain minimal API endpoints on Hlibz.Results.AspNetCore only.

This is a preview: the API may still change before 2.0.0.

https://www.nuget.org/packages/Hlibz.UseCases/2.0.0-preview.1