When a CSR API call fails on the server, Order Management doesn’t show the error. The dialog just stays open, so the rep thinks the button did nothing.
Versions: Found and worked around on EPiServer.Commerce.UI.CustomerService 14.46.2 (Commerce 14.46.2, CMS 12.34.8, .NET 10). The latest 14.x (14.47.0) and 15.x (15.5.0) have the same code.
Why it happens
CsrExceptionFilterAttribute returns new ObjectResult(new { Message, MessageDetail, StatusCode = 500 }). The 500 is only in the body, so the response goes out as HTTP 200.
The client’s axios interceptor already turns messageDetail into a message, but only for non-2xx responses, so it never runs for these errors.
Create New Order fails silently even with a real error status. createCustomerOrder calls initPurchaseOrder with no try/catch, so the rejection goes unhandled and no notification appears. With the current HTTP 200 response it’s worse: the error body is treated as a draft order and Prepare Order opens with it.
To reproduce: throw from a SavingOrder handler, then click Create New Cart in Order Management. The network tab shows a 200 with "statusCode": 500 in the body, and no message appears.
Suggested fix
Set the status on the result: new ObjectResult(...) { StatusCode = 500 }.
Wrap createCustomerOrder in the same try/catch and showNotification that createOrRefreshCart already uses.
Workaround: an always-run result filter that applies the status from the body. It has to be IAlwaysRunResultFilter, because ordinary result filters are skipped when an exception filter supplies the result.
public class CsrErrorStatusCodeResultFilter : IAlwaysRunResultFilter
{
public void OnResultExecuting(ResultExecutingContext context)
{
if (context.Result is not ObjectResult { StatusCode: null, Value: { } value } result)
return;
var type = value.GetType();
if (type.GetProperty("MessageDetail") != null
&& type.GetProperty("StatusCode")?.GetValue(value) is int status && status >= 400)
result.StatusCode = status;
}
public void OnResultExecuted(ResultExecutedContext context) { }
}
The filter fixes Create New Cart, but that relies on the shape of an internal anonymous type. Create New Order still needs a client fix.
When a CSR API call fails on the server, Order Management doesn’t show the error. The dialog just stays open, so the rep thinks the button did nothing.
Versions: Found and worked around on EPiServer.Commerce.UI.CustomerService 14.46.2 (Commerce 14.46.2, CMS 12.34.8, .NET 10). The latest 14.x (14.47.0) and 15.x (15.5.0) have the same code.
Why it happens
CsrExceptionFilterAttributereturnsnew ObjectResult(new { Message, MessageDetail, StatusCode = 500 }). The 500 is only in the body, so the response goes out as HTTP 200.messageDetailinto a message, but only for non-2xx responses, so it never runs for these errors.createCustomerOrdercallsinitPurchaseOrderwith no try/catch, so the rejection goes unhandled and no notification appears. With the current HTTP 200 response it’s worse: the error body is treated as a draft order and Prepare Order opens with it.To reproduce: throw from a
SavingOrderhandler, then click Create New Cart in Order Management. The network tab shows a 200 with"statusCode": 500in the body, and no message appears.Suggested fix
new ObjectResult(...) { StatusCode = 500 }.createCustomerOrderin the same try/catch andshowNotificationthatcreateOrRefreshCartalready uses.Workaround: an always-run result filter that applies the status from the body. It has to be
IAlwaysRunResultFilter, because ordinary result filters are skipped when an exception filter supplies the result.public class CsrErrorStatusCodeResultFilter : IAlwaysRunResultFilter { public void OnResultExecuting(ResultExecutingContext context) { if (context.Result is not ObjectResult { StatusCode: null, Value: { } value } result) return; var type = value.GetType(); if (type.GetProperty("MessageDetail") != null && type.GetProperty("StatusCode")?.GetValue(value) is int status && status >= 400) result.StatusCode = status; } public void OnResultExecuted(ResultExecutedContext context) { } }The filter fixes Create New Cart, but that relies on the shape of an internal anonymous type. Create New Order still needs a client fix.