-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathError.cs
More file actions
45 lines (35 loc) · 1005 Bytes
/
Error.cs
File metadata and controls
45 lines (35 loc) · 1005 Bytes
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
using System;
namespace FlowControl.NET;
public class Error
{
public static Error New(string message) => new()
{
Message = message
};
public static Error New(Exception ex) => new()
{
Message = ex.Message
};
public required string Message { get; init; }
public override string ToString() => $"Error: {Message}";
}
public class Error<TErrorType> : Error
{
public static Error<TErrorType> New(string message, TErrorType? type = default) => new()
{
Message = message,
Type = type
};
public static Error<TErrorType> New(TErrorType? type) => new()
{
Message = string.Empty,
Type = type
};
public static Error<TErrorType> New(Exception ex, TErrorType? type = default) => new()
{
Message = ex.Message,
Type = type
};
public required TErrorType? Type { get; init; } = default;
public override string ToString() => $"Error[{Type?.ToString() ?? "-"}]: {Message}";
}