fix: throw WrongCredentialsException in findEntry()
This commit is contained in:
parent
369e1d1945
commit
80a0d7cdcd
@ -48,8 +48,11 @@ class PCloudContentRepository extends InterceptingCloudContentRepository<PCloud,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void throwWrongCredentialsExceptionIfRequired(Exception e) {
|
private void throwWrongCredentialsExceptionIfRequired(Exception e) {
|
||||||
if (e instanceof ApiError && ((ApiError) e).errorCode() == PCloudApiErrorCodes.INVALID_ACCESS_TOKEN.getValue()) {
|
if (e instanceof ApiError) {
|
||||||
throw new WrongCredentialsException(cloud);
|
int errorCode = ((ApiError)e).errorCode();
|
||||||
|
if (errorCode == PCloudApiErrorCodes.INVALID_ACCESS_TOKEN.getValue() || errorCode == PCloudApiErrorCodes.ACCESS_TOKEN_REVOKED.getValue()) {
|
||||||
|
throw new WrongCredentialsException(cloud);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import org.cryptomator.domain.exception.BackendException;
|
|||||||
import org.cryptomator.domain.exception.CloudNodeAlreadyExistsException;
|
import org.cryptomator.domain.exception.CloudNodeAlreadyExistsException;
|
||||||
import org.cryptomator.domain.exception.NoSuchCloudFileException;
|
import org.cryptomator.domain.exception.NoSuchCloudFileException;
|
||||||
import org.cryptomator.domain.exception.authentication.NoAuthenticationProvidedException;
|
import org.cryptomator.domain.exception.authentication.NoAuthenticationProvidedException;
|
||||||
|
import org.cryptomator.domain.exception.authentication.WrongCredentialsException;
|
||||||
import org.cryptomator.domain.usecases.ProgressAware;
|
import org.cryptomator.domain.usecases.ProgressAware;
|
||||||
import org.cryptomator.domain.usecases.cloud.DataSource;
|
import org.cryptomator.domain.usecases.cloud.DataSource;
|
||||||
import org.cryptomator.domain.usecases.cloud.DownloadState;
|
import org.cryptomator.domain.usecases.cloud.DownloadState;
|
||||||
@ -96,6 +97,12 @@ class PCloudImpl {
|
|||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} catch(ApiError | IOException ex) {
|
} catch(ApiError | IOException ex) {
|
||||||
|
if (ex instanceof ApiError) {
|
||||||
|
int errorCode = ((ApiError)ex).errorCode();
|
||||||
|
if (errorCode == PCloudApiErrorCodes.INVALID_ACCESS_TOKEN.getValue() || errorCode == PCloudApiErrorCodes.ACCESS_TOKEN_REVOKED.getValue()) {
|
||||||
|
throw new WrongCredentialsException(cloud);
|
||||||
|
}
|
||||||
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user