Skip to content

Commit

Permalink
Refine error handling for Box, GoogleDrive, and revert log in Dropbox…
Browse files Browse the repository at this point in the history
… provider
  • Loading branch information
iammajid committed Oct 15, 2024
1 parent 0c1a348 commit 9e5ae76
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/CryptomatorCloudAccess/Box/BoxCloudProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public class BoxCloudProvider: CloudProvider {

private func convertStandardError(_ error: Error) -> Error {
switch error {
case let error as BoxAPIError where error.responseInfo.statusCode == 401 || error.description.contains("Invalid refresh token"):
case let error as BoxAPIError where (error.responseInfo.statusCode == 400 && error.responseInfo.rawBody?.contains("invalid_grant") == true) || error.responseInfo.statusCode == 401:
return CloudProviderError.unauthorized
case let error as BoxAPIError where error.responseInfo.statusCode == 404:
return CloudProviderError.itemNotFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public class DropboxCloudProvider: CloudProvider {
return
}
if let networkError = networkError {
CloudAccessDDLogDebug("DropboxCloudProvider: fetchItemMetadata failed with networkError: \(networkError)")
CloudAccessDDLogDebug("DropboxCloudProvider: fetchItemMetadata(at: \(cloudPath.path)) failed with networkError: \(networkError)")
reject(self.convertRequestError(networkError))
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public class GoogleDriveCloudProvider: CloudProvider {
CloudAccessDDLogDebug("GoogleDriveCloudProvider: executeQuery(\(query.requestID)) failed with error: \(error)")
if error.domain == NSURLErrorDomain, error.code == NSURLErrorNotConnectedToInternet || error.code == NSURLErrorCannotConnectToHost || error.code == NSURLErrorNetworkConnectionLost || error.code == NSURLErrorDNSLookupFailed || error.code == NSURLErrorResourceUnavailable || error.code == NSURLErrorInternationalRoamingOff {
reject(CloudProviderError.noInternetConnection)
} else if ((error.domain == kGTLRErrorObjectDomain && (error.code == 401 || error.code == 403)) || (error.domain == OIDOAuthTokenErrorDomain && error.code == -10)) {
} else if ((error.domain == kGTLRErrorObjectDomain && (error.code == 401 || error.code == 403)) || (error.domain == OIDOAuthTokenErrorDomain && error.code == OIDErrorCodeOAuth.invalidGrant.rawValue)) {
reject(CloudProviderError.unauthorized)
} else if error.domain == kGTLRErrorObjectDomain, error.code == 404 {
reject(CloudProviderError.itemNotFound)
Expand Down

0 comments on commit 9e5ae76

Please sign in to comment.