You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
Ive realized that the error handling of commands is a bit limited. I explain.
So for example if we try to do client.sticker_get("song", uri, tag) and the particular sticker doesnt exist in that uri we get a:
CommandError: [50@0] {sticker} no such sticker
But if the sticker database isnt active we get
CommandError: [5@0] {sticker} sticker database is disabled
Same error (a very clear different accompany text tho, nice) for two arguebly very different things
Dont give too much importance to the example itself, its just where i realized this, given the solution it doesnt make "much" difference; but i do belive it would be better practice to have clearer errors. Havent tried but I imagine similar things might occur with other commands.
Also it could be argued that if a sticker doesnt exist it could return None instead of error. That would make the code:
# At the start of the codetry:
# A test to see that stickers db is activatedexceptStickerDBError:
# whatever# ...played=client.sticker_get("song", song["file"], "played")
ifplayedisNone:
played=0client.sticker_set("song", song["file"], "played", int(played) +1)
But i gues thats more about what mpd itself wants to do, and it wouldnt be quite right to have a different behaviour here
Thanks for the amazing library! :D
The text was updated successfully, but these errors were encountered:
Only problem though is that these types of errors are not really specified by the MPD protocol: https://mpd.readthedocs.io/en/latest/protocol.html#stickers
So different implementations i.e. mpd vs mopibity could do different things here.
However what you can do in your application is to use the errno included in the error to tell them apart:
Hi!
Ive realized that the error handling of commands is a bit limited. I explain.
So for example if we try to do
client.sticker_get("song", uri, tag)
and the particular sticker doesnt exist in that uri we get a:But if the sticker database isnt active we get
Same error (a very clear different accompany text tho, nice) for two arguebly very different things
In a example code:
Against:
Dont give too much importance to the example itself, its just where i realized this, given the solution it doesnt make "much" difference; but i do belive it would be better practice to have clearer errors. Havent tried but I imagine similar things might occur with other commands.
Also it could be argued that if a sticker doesnt exist it could return None instead of error. That would make the code:
But i gues thats more about what mpd itself wants to do, and it wouldnt be quite right to have a different behaviour here
Thanks for the amazing library! :D
The text was updated successfully, but these errors were encountered: