Hi,
I want to send a custom exception message to client when a specific exception is fired (AbpDbConcurrencyException). Instead of doing this for each method of all my appservices I would like to change it in a global place. So for example if I have 20 AppServices with each 2-3 methods I dont want to add try/catch block in each method but instead have a place where I do this.
How can I achieve such requirement
Thanks
4 Answer(s)
-
0
Hi @
You can define a custom ExceptionFilter, see https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3280
-
0
@ismcagdas The link you sent me does not show how can you change the exception message.
-
1
Hi @antonis
If you define such an exception filter and set it's order to 1 as explained here https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3280#issuecomment-382609585 it will be executed before other filters.
In your custom exception filter you can only catch AbpDbConcurrencyException and then throw UserFriendlyException with an appropriate message. Then, it should work like you want.
Let me know If it doesn't work for you.
-
0
Thank you @ismcagdas