public async Task <T> TryMethod <T>(Task <T> task, T defaultReturnValue, WebServiceType type, string additionalErrorInfo = null) { try { _servicesStatus.SetStatus(WebServiceType.Web, true); _servicesStatus.SetStatus(type, true); return(await task); } catch (ServiceUnavailableException ex) { Handle(type, ex, additionalErrorInfo); } catch (ServiceAuthenticationException ex) { Handle(type, ex, additionalErrorInfo); } catch (ServiceException ex) { Handle(type, ex, additionalErrorInfo); } catch (WebException ex) { Handle(ex, additionalErrorInfo); } catch (HttpRequestException ex) { Handle(ex, additionalErrorInfo); } return(defaultReturnValue); }
public async Task <T> TryMethod <T>(Task <T> task, T defaultReturnValue, WebServiceType type, string additionalErrorInfo = null) { if (_servicesStatus.IsOnline(WebServiceType.LastFm)) { try { _servicesStatus.SetStatus(WebServiceType.Web, true); _servicesStatus.SetStatus(WebServiceType.LastFm, true); return(await task); } catch (Exception ex) { HandleError(ex, additionalErrorInfo); } } return(defaultReturnValue); }