File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
android/src/main/java/com/reactlibrary Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 17
17
import com .spotify .android .appremote .api .ConnectionParams ;
18
18
import com .spotify .android .appremote .api .Connector ;
19
19
import com .spotify .android .appremote .api .SpotifyAppRemote ;
20
+ import com .spotify .android .appremote .api .error .CouldNotFindSpotifyApp ;
21
+ import com .spotify .android .appremote .api .error .NotLoggedInException ;
22
+ import com .spotify .android .appremote .api .error .UserNotAuthorizedException ;
20
23
21
24
import com .lufinkey .react .eventemitter .RNEventConformer ;
22
25
@@ -56,7 +59,15 @@ public void onConnected(SpotifyAppRemote spotifyAppRemote) {
56
59
public void onFailure (Throwable throwable ) {
57
60
while (!mConnectPromises .empty ()) {
58
61
Promise promise = mConnectPromises .pop ();
59
- promise .reject (throwable );
62
+ if (throwable instanceof NotLoggedInException ) {
63
+ promise .reject (new Error ("Spotify connection failed: user is not logged in." ));
64
+ } else if (throwable instanceof UserNotAuthorizedException ) {
65
+ promise .reject (new Error ("Spotify connection failed: user is not authorized." ));
66
+ } else if (throwable instanceof CouldNotFindSpotifyApp ) {
67
+ promise .reject (new Error ("Spotify connection failed: could not find the Spotify app, it may need to be installed." ));
68
+ } else {
69
+ promise .reject (throwable );
70
+ }
60
71
}
61
72
sendEvent ("remoteDisconnected" , null );
62
73
}
You can’t perform that action at this time.
0 commit comments