2 Commits
2e04b72dba
...
7821fdb701
Author | SHA1 | Message | Date |
---|---|---|---|
![]() |
7821fdb701 |
添加 UnauthorizedException
|
3 weeks ago |
![]() |
9e7b30ef23 |
NetworkUtility:增加 Uri.Segmental 扩展方法。
|
3 weeks ago |
2 changed files with 74 additions and 4 deletions
@ -0,0 +1,46 @@ |
|||
using System; |
|||
|
|||
namespace Apewer |
|||
{ |
|||
|
|||
/// <summary>表示未授权的错误。</summary>
|
|||
/// <remarks>默认消息:Operation is not authorized.</remarks>
|
|||
public class UnauthorizedException : Exception |
|||
{ |
|||
|
|||
static string _default = FixMessage(null); |
|||
|
|||
static string FixMessage(string message) |
|||
{ |
|||
const string Preset = "Operation is not authorized."; |
|||
if (message != null) |
|||
{ |
|||
message = message.Trim(); |
|||
if (!string.IsNullOrEmpty(message)) return message; |
|||
} |
|||
|
|||
return Preset; |
|||
} |
|||
|
|||
/// <summary>获取或设置默认消息。</summary>
|
|||
public static string DefaultMessage { get => _default; set => _default = FixMessage(value); } |
|||
|
|||
/// <summary>状态。</summary>
|
|||
/// <value>Unauthorized</value>
|
|||
public virtual string Status { get => "Unauthorized"; } |
|||
|
|||
/// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
|
|||
/// <remarks>默认消息:Operation is not authorized.</remarks>
|
|||
public UnauthorizedException() : base(DefaultMessage) { } |
|||
|
|||
/// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
|
|||
/// <remarks>默认消息:Operation is not authorized.</remarks>
|
|||
public UnauthorizedException(string message) : base(FixMessage(message)) { } |
|||
|
|||
/// <summary>表示未授权的错误,此时应在前端发起授权。</summary>
|
|||
/// <remarks>默认消息:Operation is not authorized.</remarks>
|
|||
public UnauthorizedException(string message, Exception innerException) : base(FixMessage(message), innerException) { } |
|||
|
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue