Base solution for your next web application
Open Closed

Add custom button to UserFriendlyException #11187


User avatar
0
Astech created

We are using the UserFriendlyException to notify users that they have reached the user limit for their edition:

throw new UserFriendlyException(L("MaximumUserCount_Error_Message"), L("MaximumUserCount_Error_Detail", maxUserCount));

This results in the following:

We would like to add a second button next to OK that takes the user to the Upgrade page. How can we customise this functionality?

Many thanks


1 Answer(s)
  • User Avatar
    0
    sedulen created

    Hi @Astech,

    The "UserFriendlyException" class and exception modal that you are showing in your code snippet and screenshot are generic, so in order to implement something like this you would need to provide a custom implementation.

    An easy way to do this would be to define your own custom exception class, such as UserCountMaximumReachedException. Then in your UI code, you would need to modify the http-interceptor behavior. I'm not sure if this implementation has changed since the version I'm working with, but in my Angular typescript code, there are classes under MyProject.Web.Host > src > shared > common > interceptors.

    You can breakpoint this code while developing locally to see how it works, and to see how you could potentially handle a custom response in the Angular UI to your custom Exception class.

    I hope that helps! -Brian