public void OnException(ExceptionContext context)
        {
            if (!(context.Exception is DomainValidationException domainValidationException))
            {
                return;
            }

            var error = new ProblemDocument(
                "DomainValidationFailed",
                "A Domain Validation failed, see details",
                domainValidationException.DomainErrors);
            var badRequestResult = new BadRequestObjectResult(error);

            context.Result = badRequestResult;
        }
Пример #2
0
        public void OnException(ExceptionContext context)
        {
            if (!(context.Exception is NotFoundException notFoundException))
            {
                return;
            }

            var error = new ProblemDocument(
                "EntityNotFound",
                "Entity not found",
                HttpStatusCode.NotFound,
                notFoundException.Message);
            var badRequestResult = new NotFoundObjectResult(error);

            context.Result = badRequestResult;
        }
        public void OnException(ExceptionContext context)
        {
            if (!(context.Exception is ConcurrencyViolatedException concurrencyViolatedException))
            {
                return;
            }

            var error = new ProblemDocument(
                "ConcurrencyViolation",
                "Concurrency was violated, can not update entity",
                HttpStatusCode.Conflict,
                concurrencyViolatedException.Message);
            var conflictResult = new OkObjectResult(error);

            conflictResult.StatusCode = 409;
            context.Result            = conflictResult;
        }