1
- namespace MicroPlumberd . Services ;
1
+ using System . Net ;
2
+
3
+ namespace MicroPlumberd . Services ;
2
4
3
5
4
6
record CommandExecuted
@@ -7,16 +9,17 @@ record CommandExecuted
7
9
public TimeSpan Duration { get ; init ; }
8
10
}
9
11
10
- record CommandFailed
12
+ record CommandFailed : ICommandFailed
11
13
{
12
14
public Guid CommandId { get ; init ; }
13
15
public TimeSpan Duration { get ; init ; }
14
16
public string Message { get ; init ; }
17
+ public HttpStatusCode Code { get ; init ; }
15
18
16
- public static ICommandFailedEx Create ( Guid commandId , string message , TimeSpan duration , object fault )
19
+ public static ICommandFailedEx Create ( Guid commandId , string message , TimeSpan duration , HttpStatusCode code , object fault )
17
20
{
18
21
var type = typeof ( CommandFailed < > ) . MakeGenericType ( fault . GetType ( ) ) ;
19
- return ( ICommandFailedEx ) Activator . CreateInstance ( type , commandId , message , duration , fault ) ! ;
22
+ return ( ICommandFailedEx ) Activator . CreateInstance ( type , commandId , message , duration , code , fault ) ! ;
20
23
}
21
24
}
22
25
@@ -25,23 +28,26 @@ interface ICommandFailed
25
28
Guid CommandId { get ; }
26
29
TimeSpan Duration { get ; }
27
30
string Message { get ; }
28
-
31
+ public HttpStatusCode Code { get ; }
32
+
29
33
}
30
34
interface ICommandFailedEx : ICommandFailed
31
35
{
32
36
object Fault { get ; }
37
+
33
38
}
34
39
record CommandFailed < TFault > : CommandFailed , ICommandFailedEx
35
40
{
36
41
public CommandFailed ( ) { }
37
42
38
43
object ICommandFailedEx . Fault => this . Fault ;
39
- public CommandFailed ( Guid commandId , string message , TimeSpan duration , TFault Fault )
44
+ public CommandFailed ( Guid commandId , string message , TimeSpan duration , HttpStatusCode code , TFault Fault )
40
45
{
41
46
this . Fault = Fault ;
42
47
this . CommandId = commandId ;
43
48
this . Duration = duration ;
44
49
this . Message = message ;
50
+ this . Code = code ;
45
51
}
46
52
public TFault Fault { get ; init ; }
47
53
0 commit comments