Skip to content

Commit 7cfef38

Browse files
committed
examples: Fix Catches
1 parent 943dcc7 commit 7cfef38

75 files changed

Lines changed: 229 additions & 157 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎examples/authorization/authorization_code/AuthorizationCodeExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
66
import com.wrapper.spotify.model_objects.credentials.AuthorizationCodeCredentials;
77
import com.wrapper.spotify.requests.authorization.authorization_code.AuthorizationCodeRequest;
8+
import org.apache.hc.core5.http.ParseException;
89

910
import java.io.IOException;
1011
import java.net.URI;
@@ -35,7 +36,7 @@ public static void authorizationCode_Sync() {
3536
spotifyApi.setRefreshToken(authorizationCodeCredentials.getRefreshToken());
3637

3738
System.out.println("Expires in: " + authorizationCodeCredentials.getExpiresIn());
38-
} catch (IOException | SpotifyWebApiException e) {
39+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3940
System.out.println("Error: " + e.getMessage());
4041
}
4142
}
@@ -60,4 +61,4 @@ public static void authorizationCode_Async() {
6061
System.out.println("Async operation cancelled.");
6162
}
6263
}
63-
}
64+
}

‎examples/authorization/authorization_code/AuthorizationCodeRefreshExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
55
import com.wrapper.spotify.model_objects.credentials.AuthorizationCodeCredentials;
66
import com.wrapper.spotify.requests.authorization.authorization_code.AuthorizationCodeRefreshRequest;
7+
import org.apache.hc.core5.http.ParseException;
78

89
import java.io.IOException;
910
import java.util.concurrent.CancellationException;
@@ -32,7 +33,7 @@ public static void authorizationCodeRefresh_Sync() {
3233
spotifyApi.setRefreshToken(authorizationCodeCredentials.getRefreshToken());
3334

3435
System.out.println("Expires in: " + authorizationCodeCredentials.getExpiresIn());
35-
} catch (IOException | SpotifyWebApiException e) {
36+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3637
System.out.println("Error: " + e.getMessage());
3738
}
3839
}
@@ -56,4 +57,4 @@ public static void authorizationCodeRefresh_Async() {
5657
System.out.println("Async operation cancelled.");
5758
}
5859
}
59-
}
60+
}

‎examples/authorization/client_credentials/ClientCredentialsExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
55
import com.wrapper.spotify.model_objects.credentials.ClientCredentials;
66
import com.wrapper.spotify.requests.authorization.client_credentials.ClientCredentialsRequest;
7+
import org.apache.hc.core5.http.ParseException;
78

89
import java.io.IOException;
910
import java.util.concurrent.CancellationException;
@@ -29,7 +30,7 @@ public static void clientCredentials_Sync() {
2930
spotifyApi.setAccessToken(clientCredentials.getAccessToken());
3031

3132
System.out.println("Expires in: " + clientCredentials.getExpiresIn());
32-
} catch (IOException | SpotifyWebApiException e) {
33+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3334
System.out.println("Error: " + e.getMessage());
3435
}
3536
}
@@ -53,4 +54,4 @@ public static void clientCredentials_Async() {
5354
System.out.println("Async operation cancelled.");
5455
}
5556
}
56-
}
57+
}

‎examples/data/albums/GetAlbumExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
55
import com.wrapper.spotify.model_objects.specification.Album;
66
import com.wrapper.spotify.requests.data.albums.GetAlbumRequest;
7+
import org.apache.hc.core5.http.ParseException;
78

89
import java.io.IOException;
910
import java.util.concurrent.CancellationException;
@@ -26,7 +27,7 @@ public static void getAlbum_Sync() {
2627
final Album album = getAlbumRequest.execute();
2728

2829
System.out.println("Name: " + album.getName());
29-
} catch (IOException | SpotifyWebApiException e) {
30+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3031
System.out.println("Error: " + e.getMessage());
3132
}
3233
}
@@ -47,4 +48,4 @@ public static void getAlbum_Async() {
4748
System.out.println("Async operation cancelled.");
4849
}
4950
}
50-
}
51+
}

‎examples/data/albums/GetAlbumsTracksExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.wrapper.spotify.model_objects.specification.Paging;
66
import com.wrapper.spotify.model_objects.specification.TrackSimplified;
77
import com.wrapper.spotify.requests.data.albums.GetAlbumsTracksRequest;
8+
import org.apache.hc.core5.http.ParseException;
89

910
import java.io.IOException;
1011
import java.util.concurrent.CancellationException;
@@ -29,7 +30,7 @@ public static void getAlbumsTracks_Sync() {
2930
final Paging<TrackSimplified> trackSimplifiedPaging = getAlbumsTracksRequest.execute();
3031

3132
System.out.println("Total: " + trackSimplifiedPaging.getTotal());
32-
} catch (IOException | SpotifyWebApiException e) {
33+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3334
System.out.println("Error: " + e.getMessage());
3435
}
3536
}
@@ -50,4 +51,4 @@ public static void getAlbumsTracks_Async() {
5051
System.out.println("Async operation cancelled.");
5152
}
5253
}
53-
}
54+
}

‎examples/data/albums/GetSeveralAlbumsExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
55
import com.wrapper.spotify.model_objects.specification.Album;
66
import com.wrapper.spotify.requests.data.albums.GetSeveralAlbumsRequest;
7+
import org.apache.hc.core5.http.ParseException;
78

89
import java.io.IOException;
910
import java.util.concurrent.CancellationException;
@@ -26,7 +27,7 @@ public static void getSeveralAlbums_Sync() {
2627
final Album[] albums = getSeveralAlbumsRequest.execute();
2728

2829
System.out.println("Length: " + albums.length);
29-
} catch (IOException | SpotifyWebApiException e) {
30+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3031
System.out.println("Error: " + e.getMessage());
3132
}
3233
}
@@ -47,4 +48,4 @@ public static void getSeveralAlbums_Async() {
4748
System.out.println("Async operation cancelled.");
4849
}
4950
}
50-
}
51+
}

‎examples/data/artists/GetArtistExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
55
import com.wrapper.spotify.model_objects.specification.Artist;
66
import com.wrapper.spotify.requests.data.artists.GetArtistRequest;
7+
import org.apache.hc.core5.http.ParseException;
78

89
import java.io.IOException;
910
import java.util.concurrent.CancellationException;
@@ -25,7 +26,7 @@ public static void getArtist_Sync() {
2526
final Artist artist = getArtistRequest.execute();
2627

2728
System.out.println("Name: " + artist.getName());
28-
} catch (IOException | SpotifyWebApiException e) {
29+
} catch (IOException | SpotifyWebApiException | ParseException e) {
2930
System.out.println("Error: " + e.getMessage());
3031
}
3132
}
@@ -46,4 +47,4 @@ public static void getArtist_Async() {
4647
System.out.println("Async operation cancelled.");
4748
}
4849
}
49-
}
50+
}

‎examples/data/artists/GetArtistsAlbumsExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.wrapper.spotify.model_objects.specification.AlbumSimplified;
66
import com.wrapper.spotify.model_objects.specification.Paging;
77
import com.wrapper.spotify.requests.data.artists.GetArtistsAlbumsRequest;
8+
import org.apache.hc.core5.http.ParseException;
89

910
import java.io.IOException;
1011
import java.util.concurrent.CancellationException;
@@ -30,7 +31,7 @@ public static void getArtistsAlbums_Sync() {
3031
final Paging<AlbumSimplified> albumSimplifiedPaging = getArtistsAlbumsRequest.execute();
3132

3233
System.out.println("Total: " + albumSimplifiedPaging.getTotal());
33-
} catch (IOException | SpotifyWebApiException e) {
34+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3435
System.out.println("Error: " + e.getMessage());
3536
}
3637
}
@@ -51,4 +52,4 @@ public static void getArtistsAlbums_Async() {
5152
System.out.println("Async operation cancelled.");
5253
}
5354
}
54-
}
55+
}

‎examples/data/artists/GetArtistsRelatedArtistsExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
55
import com.wrapper.spotify.model_objects.specification.Artist;
66
import com.wrapper.spotify.requests.data.artists.GetArtistsRelatedArtistsRequest;
7+
import org.apache.hc.core5.http.ParseException;
78

89
import java.io.IOException;
910
import java.util.concurrent.CancellationException;
@@ -26,7 +27,7 @@ public static void getArtistsRelatedArtists_Sync() {
2627
final Artist[] artists = getArtistsRelatedArtistsRequest.execute();
2728

2829
System.out.println("Length: " + artists.length);
29-
} catch (IOException | SpotifyWebApiException e) {
30+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3031
System.out.println("Error: " + e.getMessage());
3132
}
3233
}
@@ -47,4 +48,4 @@ public static void getArtistsRelatedArtists_Async() {
4748
System.out.println("Async operation cancelled.");
4849
}
4950
}
50-
}
51+
}

‎examples/data/artists/GetArtistsTopTracksExample.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
66
import com.wrapper.spotify.model_objects.specification.Track;
77
import com.wrapper.spotify.requests.data.artists.GetArtistsTopTracksRequest;
8+
import org.apache.hc.core5.http.ParseException;
89

910
import java.io.IOException;
1011
import java.util.concurrent.CancellationException;
@@ -28,7 +29,7 @@ public static void getArtistsTopTracks_Sync() {
2829
final Track[] tracks = getArtistsTopTracksRequest.execute();
2930

3031
System.out.println("Length: " + tracks.length);
31-
} catch (IOException | SpotifyWebApiException e) {
32+
} catch (IOException | SpotifyWebApiException | ParseException e) {
3233
System.out.println("Error: " + e.getMessage());
3334
}
3435
}
@@ -49,4 +50,4 @@ public static void getArtistsTopTracks_Async() {
4950
System.out.println("Async operation cancelled.");
5051
}
5152
}
52-
}
53+
}

0 commit comments

Comments
 (0)