@@ -61,10 +61,17 @@ protected IActionResult HandleCommandResponse<TResponse, TError>(CommandResponse
6161 private IActionResult HandleErrorCommandResponse < TError > ( CommandResponse < TError > response )
6262 where TError : Enumeration
6363 {
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
6571 {
6672 ErrorResponseType . PlainText => MapErrorCommandResponseToPlainText ( response ) ,
6773 ErrorResponseType . ProblemDetails => MapErrorCommandResponseToProblemDetails ( response ) ,
74+ ErrorResponseType . Cqrs => MapErrorCommandResponseToCqrsResponse ( response ) ,
6875 ErrorResponseType . Custom => CustomErrorCommandResponseMap ( response ) ,
6976 _ => throw new ArgumentOutOfRangeException (
7077 $ "Unsupported CommandErrorResponseType: { CqrsHttpOptions . CommandErrorResponseType } ")
@@ -90,6 +97,12 @@ protected virtual IActionResult CustomErrorCommandResponseMap<TError>(CommandRes
9097 return MapErrorCommandResponseToPlainText ( response ) ;
9198 }
9299
100+ private IActionResult MapErrorCommandResponseToCqrsResponse < TError > ( CommandResponse < TError > response )
101+ where TError : Enumeration
102+ {
103+ return BadRequest ( response ) ;
104+ }
105+
93106 private IActionResult MapErrorCommandResponseToProblemDetails < TError > ( CommandResponse < TError > response )
94107 where TError : Enumeration
95108 {
0 commit comments