From 749508871ba2c527545aee532f6731ff4939e96f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 6 Feb 2017 09:55:35 -0500 Subject: [PATCH] Handle all exceptions from API calls --- src/App/Repositories/AccountsApiRepository.cs | 4 ++-- src/App/Repositories/ApiRepository.cs | 10 +++++----- src/App/Repositories/BaseApiRepository.cs | 4 ++-- src/App/Repositories/CipherApiRepository.cs | 6 +++--- src/App/Repositories/ConnectApiRepository.cs | 2 +- src/App/Repositories/DeviceApiRepository.cs | 4 ++-- src/App/Repositories/FolderApiRepository.cs | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/App/Repositories/AccountsApiRepository.cs b/src/App/Repositories/AccountsApiRepository.cs index ab05c5cb0..84000e096 100644 --- a/src/App/Repositories/AccountsApiRepository.cs +++ b/src/App/Repositories/AccountsApiRepository.cs @@ -44,7 +44,7 @@ namespace Bit.App.Repositories return ApiResult.Success(response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } @@ -76,7 +76,7 @@ namespace Bit.App.Repositories return ApiResult.Success(response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } diff --git a/src/App/Repositories/ApiRepository.cs b/src/App/Repositories/ApiRepository.cs index de76cf17d..627d66461 100644 --- a/src/App/Repositories/ApiRepository.cs +++ b/src/App/Repositories/ApiRepository.cs @@ -55,7 +55,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject(responseContent); return ApiResult.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } @@ -95,7 +95,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject>(responseContent); return ApiResult>.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException>(); } @@ -135,7 +135,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject(responseContent); return ApiResult.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } @@ -175,7 +175,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject(responseContent); return ApiResult.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } @@ -213,7 +213,7 @@ namespace Bit.App.Repositories return ApiResult.Success(response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } diff --git a/src/App/Repositories/BaseApiRepository.cs b/src/App/Repositories/BaseApiRepository.cs index fdbe3fdb6..24d3abdba 100644 --- a/src/App/Repositories/BaseApiRepository.cs +++ b/src/App/Repositories/BaseApiRepository.cs @@ -84,7 +84,7 @@ namespace Bit.App.Repositories TokenService.RefreshToken = tokenResponse.RefreshToken; TokenService.AuthBearer = null; } - catch(WebException) + catch { return webException.Invoke(); } @@ -119,7 +119,7 @@ namespace Bit.App.Repositories TokenService.Token = tokenResponse.AccessToken; TokenService.RefreshToken = tokenResponse.RefreshToken; } - catch(WebException) + catch { return webException.Invoke(); } diff --git a/src/App/Repositories/CipherApiRepository.cs b/src/App/Repositories/CipherApiRepository.cs index 946b6cec7..85d72db04 100644 --- a/src/App/Repositories/CipherApiRepository.cs +++ b/src/App/Repositories/CipherApiRepository.cs @@ -54,7 +54,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject(responseContent); return ApiResult.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } @@ -94,7 +94,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject>(responseContent); return ApiResult>.Success(responseObj, response.StatusCode); } - catch(WebException e) + catch { return HandledWebException>(); } @@ -134,7 +134,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject(responseContent); return ApiResult.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } diff --git a/src/App/Repositories/ConnectApiRepository.cs b/src/App/Repositories/ConnectApiRepository.cs index fb83e5001..cbb18f3e3 100644 --- a/src/App/Repositories/ConnectApiRepository.cs +++ b/src/App/Repositories/ConnectApiRepository.cs @@ -60,7 +60,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject(responseContent); return ApiResult.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } diff --git a/src/App/Repositories/DeviceApiRepository.cs b/src/App/Repositories/DeviceApiRepository.cs index 5d99d721b..29f5a8840 100644 --- a/src/App/Repositories/DeviceApiRepository.cs +++ b/src/App/Repositories/DeviceApiRepository.cs @@ -51,7 +51,7 @@ namespace Bit.App.Repositories return ApiResult.Success(response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } @@ -84,7 +84,7 @@ namespace Bit.App.Repositories return ApiResult.Success(response.StatusCode); } - catch(WebException) + catch { return HandledWebException(); } diff --git a/src/App/Repositories/FolderApiRepository.cs b/src/App/Repositories/FolderApiRepository.cs index 79d99808d..c23048902 100644 --- a/src/App/Repositories/FolderApiRepository.cs +++ b/src/App/Repositories/FolderApiRepository.cs @@ -54,7 +54,7 @@ namespace Bit.App.Repositories var responseObj = JsonConvert.DeserializeObject>(responseContent); return ApiResult>.Success(responseObj, response.StatusCode); } - catch(WebException) + catch { return HandledWebException>(); }