-
Notifications
You must be signed in to change notification settings - Fork 0
/
SparrowException.cs
38 lines (32 loc) · 1.29 KB
/
SparrowException.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
using Sparrow.Core;
namespace Sparrow.API.Exceptions;
public class SparrowException : Exception
{
public SparrowException(string message, string technicalMessage = "", int? errorCode = null)
: base(message)
{
ErrorCode = errorCode;
TechnicalMessage = technicalMessage;
Severity = LogSeverity.Error;
}
public SparrowException(string message, string technicalMessage, Exception innerException, int? errorCode = null)
: base(message, innerException)
{
ErrorCode = errorCode;
TechnicalMessage = technicalMessage;
Severity = LogSeverity.Error;
}
public int? ErrorCode { get; protected set; }
/// <summary>
/// Technical-details are not allowed to be shown to the user.
/// Just log them or use them internally by software-technicians.
/// </summary>
public string TechnicalMessage { get; protected set; }
/// <summary>
/// Severity of the exception. The main usage will be for logs and monitoring.
/// This way we can distinguish various exceptions in logs,
/// Think about the difference of between severity of a ValidationException and an Exception related to DB connection or Infrastructure.
/// Default: Error.
/// </summary>
public LogSeverity Severity { get; protected set; }
}