@@ -61,10 +61,17 @@ protected IActionResult HandleCommandResponse<TResponse, TError>(CommandResponse
61
61
private IActionResult HandleErrorCommandResponse < TError > ( CommandResponse < TError > response )
62
62
where TError : Enumeration
63
63
{
64
- return CqrsHttpOptions . CommandErrorResponseType switch
64
+ var errorResponseType = CqrsHttpOptions . CommandErrorResponseType ;
65
+ if ( Request . Headers . Accept . Contains ( "application/cqrs" ) )
66
+ {
67
+ errorResponseType = ErrorResponseType . Cqrs ;
68
+ }
69
+
70
+ return errorResponseType switch
65
71
{
66
72
ErrorResponseType . PlainText => MapErrorCommandResponseToPlainText ( response ) ,
67
73
ErrorResponseType . ProblemDetails => MapErrorCommandResponseToProblemDetails ( response ) ,
74
+ ErrorResponseType . Cqrs => MapErrorCommandResponseToCqrsResponse ( response ) ,
68
75
ErrorResponseType . Custom => CustomErrorCommandResponseMap ( response ) ,
69
76
_ => throw new ArgumentOutOfRangeException (
70
77
$ "Unsupported CommandErrorResponseType: { CqrsHttpOptions . CommandErrorResponseType } ")
@@ -90,6 +97,12 @@ protected virtual IActionResult CustomErrorCommandResponseMap<TError>(CommandRes
90
97
return MapErrorCommandResponseToPlainText ( response ) ;
91
98
}
92
99
100
+ private IActionResult MapErrorCommandResponseToCqrsResponse < TError > ( CommandResponse < TError > response )
101
+ where TError : Enumeration
102
+ {
103
+ return BadRequest ( response ) ;
104
+ }
105
+
93
106
private IActionResult MapErrorCommandResponseToProblemDetails < TError > ( CommandResponse < TError > response )
94
107
where TError : Enumeration
95
108
{
0 commit comments