Minor refactoring

pull/279/head
Halil İbrahim Kalkan 7 years ago
parent 61eaff79ea
commit fe36ede55b

@ -98,13 +98,13 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
protected virtual void TryToLocalizeExceptionMessage(Exception exception, RemoteServiceErrorInfo errorInfo)
{
//TODO: For test purpose
if (!(exception is IHasErrorCode exceptionWithErrorCode))
{
return;
}
if (!exceptionWithErrorCode.Code.Contains(":"))
if (exceptionWithErrorCode.Code.IsNullOrWhiteSpace() ||
!exceptionWithErrorCode.Code.Contains(":"))
{
return;
}
@ -119,7 +119,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
var stringLocalizer = _stringLocalizerFactory.Create(localizationResourceType);
var localizedString = stringLocalizer[exceptionWithErrorCode.Code];
if (localizedString.ResourceNotFound)
if (!localizedString.ResourceNotFound)
{
return;
}
@ -268,15 +268,6 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling
protected virtual string L(string name)
{
//TODO: Localization?
//try
//{
// return _localizationManager.GetString(AbpWebConsts.LocalizaionSourceName, name);
//}
//catch (Exception)
//{
// return name;
//}
return name;
}
}

@ -1,4 +1,5 @@
using System;
using System.Runtime.Serialization;
using Microsoft.Extensions.Logging;
using Volo.Abp.ExceptionHandling;
using Volo.Abp.Logging;
@ -13,18 +14,25 @@ namespace Volo.Abp
public LogLevel LogLevel { get; set; } = LogLevel.Warning;
public override string Message => base.Message ?? Code;
public BusinessException()
{
}
public BusinessException(string code, string message = null, string details = null)
: base(message)
public BusinessException(string code = null, string message = null, string details = null, Exception innerException = null)
: base(message, innerException)
{
Code = code;
Details = details;
}
/// <summary>
/// Constructor for serializing.
/// </summary>
public BusinessException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context)
{
}
}
}
Loading…
Cancel
Save