Hi. I Call appService's methods from Windows Application with this code:
var res = AsyncHelper.RunSync(() => testClient.Object.GetInstanceInfoByCode(input));
Is it possible to receive ApbUserFriendlyException message created by appService's Method?
7 Answer(s)
-
0
Hi,
For the first option, You can handle AbpRemoteCallException and catch the excpetion. Second way, you can override AbpWebApiClient's PostAsync method. Then derive all of your DTOs in windows app from a base DTO which contains an ErrorInfo field.
In overriden PostAsync method method, you can handle AbpRemoteCallException and set ErrorInfo of your result DTO.
-
0
Hi
For the first option, You can handle AbpRemoteCallException and catch the excpetion.
I call method like this
try { return await _abpWebApiClient.PostAsync<GetInstanceInfoByCodeOutput>(BaseUrl + "api/services/isirids/dashboard/GetInstanceInfoByCode", input); } catch (AbpRemoteCallException ex) { throw new Exception(ex.Message); }
for every exception raised from server I got this
Could not made request to http://localhost/ISD.Web//api/services/isirids/dashboard/GetInstanceInfoByCode! StatusCode: InternalServerError, ReasonPhrase: Internal Server Error
AND for secend way, Please example?! :shock:
-
0
Hi,
In order to go with my second suggestion the error message should not contain
ReasonPhrase: Internal Server Error
So maybe I'm wrong, let me check it again and get back to you.
Thanks.
-
0
any solution?!
-
0
Why not just try-catch it since application service's exceptions are not caught by the framework for a Windows application. (As I understand you directly use app service from a windows desktop app)
-
0
Yes. I use app service from windows desktop app directly. Is it correct way? if yes, how windows app can know about actual error occurred in service?
-
0
Hi,
Yes, this is the correct way.
how windows app can know about actual error occurred in service
You already directly catch the exception without any filtering. So, you can know the error details. Always use application service inside a try-catch method (and probably you want to show the error message to the user in the catch block).