Base solution for your next web application
Open Closed

Custom UserFriendlyException #3248


User avatar
0
imad created

Hi,

In my application service, I need to send additional data to the client when I throw UserFriendlyException, so I created my own exception class that inherit UserFriendlyException and added my own custom properties.

However on the client side, when calling the application service method, I am unable to get the new custom properties added, do i need to register my custom exception somewhere?

Also on the client side and based on the error code thrown, i need to provide my own handling and prevent the default error message that appears, how to cancel this behavior based on error code.

ex:

vm.save = function () { vm.saving = true; appService.update(vm.entity) .then(function () { abp.notify.info(app.localize('SavedSuccessfully')); $uibModalInstance.close(); }, function (result) { <ins>//I want to cancel the default error message and show my own handling with the new custom properties</ins> vm.saving = false;
}).finally(function () { vm.saving = false; }); };


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think this is possible but requires some work.

    First, you need to create your version of ErrorInfoConverter similar to this one and replace default with your version. <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Common/Web/Models/DefaultErrorInfoConverter.cs">https://github.com/aspnetboilerplate/as ... nverter.cs</a>

    Then you need to override abp.ajax.showError, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.Web.Resources/Abp/Framework/scripts/libs/abp.jquery.js#L69">https://github.com/aspnetboilerplate/as ... ery.js#L69</a>