Skip to content

Conversation

@alperozturk96
Copy link
Contributor

@alperozturk96 alperozturk96 commented Aug 18, 2025

Issue

Instead of handling UnknownErrorException, network-related exceptions can be detected and managed directly on the client side. To achieve that, SSO library should detect and throw correct error.

java.lang.RuntimeException: [com.nextcloud.android](http://com.nextcloud.android/).sso.exceptions.UnknownErrorException: Unable to resolve host "[cloud.example.com](http://cloud.example.com/)": No address associated with hostname
at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow([ExceptionHelper.java:46](http://exceptionhelper.java:46/))
at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet([BlockingMultiObserver.java:93](http://blockingmultiobserver.java:93/))
at io.reactivex.Maybe.blockingGet([Maybe.java:2321](http://maybe.java:2321/))
at io.reactivex.Observable.blockingSingle([Observable.java:5381](http://observable.java:5381/))
at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pullRemoteChanges([NotesServerSyncTask.java:225](http://notesserversynctask.java:225/))
at [it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run](http://it.niedermann.owncloud.notes.persistence.notesserversynctask.run/)([NotesServerSyncTask.java:102](http://notesserversynctask.java:102/))
at java.util.concurrent.Executors$RunnableAdapter.call([Executors.java:524](http://executors.java:524/))
at [java.util.concurrent.FutureTask.run](http://java.util.concurrent.futuretask.run/)([FutureTask.java:317](http://futuretask.java:317/))
at java.util.concurrent.ThreadPoolExecutor.runWorker([ThreadPoolExecutor.java:1156](http://threadpoolexecutor.java:1156/))
at java.util.concurrent.ThreadPoolExecutor$Worker.run([ThreadPoolExecutor.java:651](http://threadpoolexecutor.java:651/))
at [java.lang.Thread.run](http://java.lang.thread.run/)([Thread.java:1119](http://thread.java:1119/))
Caused by: [com.nextcloud.android](http://com.nextcloud.android/).sso.exceptions.UnknownErrorException: Unable to resolve host "[cloud.example.com](http://cloud.example.com/)": No address associated with hostname
at [com.nextcloud.android](http://com.nextcloud.android/).sso.api.AidlNetworkRequest.performNetworkRequestV2([AidlNetworkRequest.java:179](http://aidlnetworkrequest.java:179/))
at [com.nextcloud.android](http://com.nextcloud.android/).sso.api.NextcloudAPI.performNetworkRequestV2([NextcloudAPI.java:159](http://nextcloudapi.java:159/))
at [com.nextcloud.android](http://com.nextcloud.android/).sso.api.NextcloudAPI.lambda$performRequestObservableV2$0([NextcloudAPI.java:97](http://nextcloudapi.java:97/))
at [com.nextcloud.android](http://com.nextcloud.android/).sso.api.NextcloudAPI.$r8$lambda$af7W9mq2B0ZrhVJwZd-ibFp8T3Y(Unknown Source:0)
at [com.nextcloud.android](http://com.nextcloud.android/).sso.api.NextcloudAPI$$ExternalSyntheticLambda1.subscribe(D8$$SyntheticClass:0)
at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual([ObservableFromPublisher.java:31](http://observablefrompublisher.java:31/))
at io.reactivex.Observable.subscribe([Observable.java:12284](http://observable.java:12284/))
at io.reactivex.internal.operators.observable.ObservableSingleMaybe.subscribeActual([ObservableSingleMaybe.java:31](http://observablesinglemaybe.java:31/))
at io.reactivex.Maybe.subscribe([Maybe.java:4290](http://maybe.java:4290/))
at io.reactivex.Maybe.blockingGet([Maybe.java:2320](http://maybe.java:2320/))

Example usage

For example, in the Notes app, rather than displaying an error dialog, we can notify the user via a snackbar. This approach avoids aggressively handling transient errors and prevents unnecessary disruption to the user’s workflow.

Screenshot 2025-08-18 at 13 34 17

Signed-off-by: alperozturk <alper_ozturk@proton.me>
@alperozturk96 alperozturk96 added the 3. to review Waiting for reviews label Aug 18, 2025
final var cause = exception.getCause().getCause();
yield new NextcloudHttpRequestFailedException(context, statusCode, cause);
Throwable rootCause = exception.getCause();
if (rootCause != null && rootCause.getMessage() != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check NPE.

new NextcloudFilesAppAccountPermissionNotGrantedException(context);
default -> new UnknownErrorException(exception.getMessage());
default -> {
if (isNetworkConnectivityError(exception)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check exception and throw NextcloudNetworkException

@alperozturk96 alperozturk96 merged commit c8e05ec into main Aug 19, 2025
6 checks passed
@alperozturk96 alperozturk96 deleted the feat/add-network-error-type-check branch August 19, 2025 07:15
@AndyScherzinger AndyScherzinger added this to the SSO Library 2.0.0 milestone Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants