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.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
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 ErrorAND for secend way, Please example?! :shock:
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi,
In order to go with my second suggestion the error message should not contain
ReasonPhrase: Internal Server ErrorSo maybe I'm wrong, let me check it again and get back to you.
Thanks.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
any solution?!
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
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)
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
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?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
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).
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)