SpotifyApiBundle icon indicating copy to clipboard operation
SpotifyApiBundle copied to clipboard

Handling of negative responses

Open hvt opened this issue 10 years ago • 2 comments

Hey there, nice library ;].

I was wondering what your thoughts are to use exceptions when negative responses are received. In my opinion this would lead to much cleaner code. So instead of:

$track = $this->get('spotify.api.lookup')->getTrack($spotifyUri);
if (is_array($track)) {
    // handle error
} else {
    // use track
}

You get:

try {
    $track = $this->get('spotify.api.lookup')->getTrack($spotifyUri);
    // use track
} catch (SpotifyException $e) {
    // handle exception
}

hvt avatar Dec 11 '13 20:12 hvt

Hmmm, interesting...

I'll work as soon as possible with this feature. You're right, this is something must be changed and managed as expected ( with exceptions )

If you want, feel free to contribute :D:D:D

mmoreram avatar Dec 12 '13 19:12 mmoreram

@mmoreram thanks for the invitation. I'm using it in a pet project in which I don't put a lot of time. But we'll see who gets to this first ;].

hvt avatar Dec 18 '13 18:12 hvt