mirror of https://github.com/abpframework/abp.git
12 changed files with 118 additions and 32 deletions
@ -0,0 +1,22 @@ |
|||
using Volo.Abp; |
|||
|
|||
namespace Microsoft.AspNetCore.Http |
|||
{ |
|||
public static class HttpRequestExtensions |
|||
{ |
|||
private const string RequestedWithHeader = "X-Requested-With"; |
|||
private const string XmlHttpRequest = "XMLHttpRequest"; |
|||
|
|||
public static bool IsAjax(this HttpRequest request) |
|||
{ |
|||
Check.NotNull(request, nameof(request)); |
|||
|
|||
if (request.Headers == null) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return request.Headers[RequestedWithHeader] == XmlHttpRequest; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
using System; |
|||
using Microsoft.Extensions.Logging; |
|||
using Volo.Abp.ExceptionHandling; |
|||
using Volo.Abp.Logging; |
|||
|
|||
namespace Volo.Abp |
|||
{ |
|||
public class BusinessException : Exception, IBusinessException, IHasErrorDetails, IHasLogLevel |
|||
{ |
|||
public string Code { get; set; } |
|||
|
|||
public string Details { get; set; } |
|||
|
|||
public LogLevel LogLevel { get; set; } = LogLevel.Warning; |
|||
|
|||
public BusinessException() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public BusinessException(string code, string message = null, string details = null) |
|||
: base(message) |
|||
{ |
|||
Code = code; |
|||
Details = details; |
|||
} |
|||
} |
|||
} |
|||
@ -1,4 +1,4 @@ |
|||
namespace Volo.Abp |
|||
namespace Volo.Abp.ExceptionHandling |
|||
{ |
|||
public interface IHasErrorCode |
|||
{ |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.ExceptionHandling |
|||
{ |
|||
public interface IHasErrorDetails |
|||
{ |
|||
string Details { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.ExceptionHandling; |
|||
|
|||
namespace Volo.Abp |
|||
{ |
|||
public interface IBusinessException : IHasErrorCode |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.Localization |
|||
{ |
|||
public static class LocalizationResourceExtensions |
|||
{ |
|||
public static LocalizationResource InheritFrom([NotNull] this LocalizationResource resource, [NotNull] params Type[] baseResourceTypes) |
|||
{ |
|||
Check.NotNull(resource, nameof(resource)); |
|||
Check.NotNull(baseResourceTypes, nameof(baseResourceTypes)); |
|||
|
|||
resource.BaseResourceTypes.AddRange(baseResourceTypes); |
|||
|
|||
return resource; |
|||
} |
|||
} |
|||
} |
|||
@ -1,13 +1,9 @@ |
|||
using Volo.Abp.ExceptionHandling; |
|||
|
|||
namespace Volo.Abp.UI |
|||
{ |
|||
/* TODO: |
|||
* - define an interface to split Details, like IHasExceptionDetails |
|||
*/ |
|||
|
|||
public interface IUserFriendlyException |
|||
public interface IUserFriendlyException : IHasErrorDetails |
|||
{ |
|||
string Message { get; } |
|||
|
|||
string Details { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue