Browse Source

Domain validation errors must throw domain exceptions.

pull/144/head
dsanz 7 years ago
parent
commit
5fed56db51
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      src/Services/Ordering/Ordering.API/Application/Decorators/ValidatorDecorator.cs

+ 3
- 2
src/Services/Ordering/Ordering.API/Application/Decorators/ValidatorDecorator.cs View File

@ -1,5 +1,6 @@
using FluentValidation; using FluentValidation;
using MediatR; using MediatR;
using Ordering.Domain.Exceptions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -33,8 +34,8 @@ namespace Ordering.API.Application.Decorators
if (failures.Any()) if (failures.Any())
{ {
throw new ValidationException(
$"Command Validation Errors for type {typeof(TRequest).Name}", failures);
throw new OrderingDomainException(
$"Command Validation Errors for type {typeof(TRequest).Name}", new ValidationException("Validation exception", failures));
} }
var response = await _inner.Handle(message); var response = await _inner.Handle(message);


Loading…
Cancel
Save