-
Notifications
You must be signed in to change notification settings - Fork 1
/
BaseHttpException.cs
67 lines (61 loc) · 2.24 KB
/
BaseHttpException.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
67
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Runtime.Serialization;
namespace Shared.WebApi.Core.Exceptions
{
/// <summary>
/// Represents a base HTTP exception.
/// </summary>
[Serializable]
[ExcludeFromCodeCoverage]
public abstract class BaseHttpException : Exception
{
/// <summary>
/// Creates a new instance of the BaseHttpException class.
/// </summary>
protected BaseHttpException()
{
}
/// <summary>
/// Creates a new instance of the BaseHttpException class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="errorCode">The error code.</param>
protected BaseHttpException(string? message, int errorCode) : base(message)
{
ErrorCode = errorCode;
}
/// <summary>
/// Creates a new instance of the BaseHttpException class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="innerException">The exception.</param>
/// <param name="errorCode">The error code.</param>
protected BaseHttpException(string? message, Exception? innerException, int errorCode) : base(message, innerException)
{
ErrorCode = errorCode;
}
/// <summary>
/// Creates a new instance of the BaseHttpException class.
/// </summary>
/// <param name="serializationInfo">The serialization info.</param>
/// <param name="streamingContext">The streaming context.</param>
protected BaseHttpException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
{
}
/// <summary>
/// The error code correlating to the error that occurred.
/// </summary>
[Required]
public int ErrorCode { get; }
/// <summary>
/// Gets the System.Net.HttpStatusCode associated with the exception that was thrown.
/// </summary>
public virtual HttpStatusCode GetHttpStatusCode()
{
return HttpStatusCode.InternalServerError;
}
}
}