Hello! We're using CMS & Commerce with external Single Sign-On provider (OIDC). We would like administrators to be able to modify customer data via Commerce Manager, and make these changes reflect in login provider. To achieve that, we implemented custom IPlugin that updates customer data in login provider on CustomerContact edit.However, there might be situations when customer cannot be modified (for example, due to invalid data entered by administrator). Throwing exception from IPlugin reverts the change, but causes whole web request fail - so the administrator see general 500 error page, which is unwanted. Are we able to fail an action "gracefully" from that plugin, or somehow cancel it in a way that administrator would see what happened (or - at best - which field caused an error)? Epi 11.18.X, Commerce 13.14.XKind regards
How you are throwing an exception in IPlugin?
I'm using the following code snippet and it works fine
var contact = context.Request.Target as CustomerContact;
if (contact == null) throw new NotSupportedException("Support create Contact only!");
The exact code looks very similar - more or less like
var result = // API call
throw new ApplicationException("This action cannot be performed");
In terms of effect, it works - change in Commerce DB is rollbacked and previous state of the user is preserved. However, I'd like the administrator to see something less scary than error 500 page... ;)
You can simply return like
Ideally, it should be returned with the message. I'll do some experiments with my IPlugin and will let you know.
I'm doing all form validation on the client-side.
As I said in the above reply, you can use return if your result is not Succeeded and it would not give 500 error to the user.
To show a user-friendly message...
I assume you have already generated Typed Business Foundation classes
You need to edit ContentFrame.aspx file to show a user-friendly error.
You can use Js to get the message from BE & show or simply put it in session and get it in aspx file (sorry by webforms knowledge is a bit rusty)
All the above seems like workarounds. @Quan probably know more about it.