forked from Avanade/Beef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AuthorizationException.cs
66 lines (58 loc) · 2.29 KB
/
AuthorizationException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/Beef
using System;
using System.Net;
namespace Beef
{
/// <summary>
/// Represents an <b>Authorization</b> exception.
/// </summary>
public class AuthorizationException : Exception, IBusinessException
{
/// <summary>
/// Get or sets the <see cref="ShouldBeLogged"/> value.
/// </summary>
public static bool ShouldExceptionBeLogged { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="AuthorizationException"/> class.
/// </summary>
public AuthorizationException() : this(null!) { }
/// <summary>
/// Initializes a new instance of the <see cref="AuthorizationException"/> class with a specified messsage.
/// </summary>
/// <param name="message">The message text.</param>
public AuthorizationException(string? message)
: base(message ?? new LText("Beef.AuthorizationException"))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AuthorizationException"/> class with a specified messsage and inner exception.
/// </summary>
/// <param name="message">The message text.</param>
/// <param name="innerException">The inner <see cref="Exception"/>.</param>
public AuthorizationException(string? message, Exception innerException)
: base(message ?? new LText("Beef.AuthorizationException"), innerException)
{
}
/// <summary>
/// Gets the <see cref="ErrorType"/> (see <see cref="ErrorType.AuthorizationError"/>).
/// </summary>
public ErrorType ErrorType
{
get { return ErrorType.AuthorizationError; }
}
/// <summary>
/// Gets the corresponding <see cref="HttpStatusCode"/>.
/// </summary>
public HttpStatusCode StatusCode
{
get { return HttpStatusCode.Forbidden; }
}
/// <summary>
/// Indicates whether the <see cref="Exception"/> should be logged (returns the <see cref="ShouldExceptionBeLogged"/> value).
/// </summary>
public bool ShouldBeLogged
{
get { return ShouldExceptionBeLogged; }
}
}
}