diff --git a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs index 2e1ef471a2..141fa3a7f4 100644 --- a/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs +++ b/framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/DefaultHttpExceptionStatusCodeFinder.cs @@ -3,6 +3,7 @@ using System.Net; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Volo.Abp.Authorization; +using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities; using Volo.Abp.ExceptionHandling; @@ -55,6 +56,11 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling { return HttpStatusCode.NotFound; } + + if (exception is AbpDbConcurrencyException) + { + return HttpStatusCode.Conflict; + } if (exception is NotImplementedException) { diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs index 7d6da59e81..a96797ce40 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using Volo.Abp.Authorization; +using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Domain.Entities; using Volo.Abp.ExceptionHandling; @@ -58,14 +59,19 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling exception = TryToGetActualException(exception); - if (exception is EntityNotFoundException) + if (exception is AbpRemoteCallException remoteCallException) { - return CreateEntityNotFoundError(exception as EntityNotFoundException); + return remoteCallException.Error; } - if (exception is AbpRemoteCallException remoteCallException) + if (exception is AbpDbConcurrencyException) { - return remoteCallException.Error; + return new RemoteServiceErrorInfo(L["AbpDbConcurrencyErrorMessage"]); + } + + if (exception is EntityNotFoundException) + { + return CreateEntityNotFoundError(exception as EntityNotFoundException); } var errorInfo = new RemoteServiceErrorInfo(); @@ -169,7 +175,7 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling return new RemoteServiceErrorInfo(exception.Message); } - + protected virtual Exception TryToGetActualException(Exception exception) { if (exception is AggregateException && exception.InnerException != null) diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/en.json b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/en.json index 62b599b7d1..5b50d19b3a 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/en.json +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/en.json @@ -13,6 +13,7 @@ "DefaultErrorMessage404": "Resource not found!", "DefaultErrorMessage404Detail": "The resource requested could not found on the server!", "EntityNotFoundErrorMessage": "There is no entity {0} with id = {1}!", + "AbpDbConcurrencyErrorMessage": "The data you have submitted has already changed by another user/client. Please discard the changes you've done and try from the beginning.", "Error": "Error", "UnhandledException": "Unhandled exception!", "401Message": "Unauthorized", diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/tr.json b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/tr.json index da199b2707..a1c10f3d13 100644 --- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/tr.json +++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/ExceptionHandling/Localization/tr.json @@ -13,6 +13,7 @@ "DefaultErrorMessage404": "Kaynak bulunamadı!", "DefaultErrorMessage404Detail": "İstenilen kaynak sunucuda bulunamadı.", "EntityNotFoundErrorMessage": "Id değeri {1} olan {0} türünden bir nesne bulunamadı!", + "AbpDbConcurrencyErrorMessage": "Gönderdiğiniz veri başka bir kullanıcı/istemci tarafından değiştirilmiş. Lütfen işlemi iptal edip baştan deneyin.", "Error": "Hata", "UnhandledException": "Yakalanmamış hata!", "401Message": "Yetkisiz İşlem",