Closed mweinelt closed 3 years ago
Could you add this to https://github.com/Mic92/python-mpd2/blob/master/examples/errorhandling.py as well?
On Mon, Jan 18, 2021 at 01:12:59AM -0800, Jörg Thalheim wrote:
Could you add this to https://github.com/Mic92/python-mpd2/blob/master/examples/errorhandling.py as well?
Sure thing.
How close to we want to stick to the protocols nomenclature? Specifically:
error: numeric value of one of the ACK_ERROR constants defined in src/protocol/Ack.hxx.
command_listNum: offset of the command that caused the error in a Command List. An error will always cause a command list to terminate at the command that causes the error.
current_command: name of the command, in a Command List, that was executing when the error occurred.
message_text: some (hopefully) informative text that describes the nature of the error.
https://www.musicpd.org/doc/html/protocol.html#failure-responses
-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Mic92/python-mpd2/pull/160#issuecomment-762104596
Oh and I think we could include the error definitions, to make the resulting code more readable. Sadly enums are 3.4+ only.
Oh and I think we could include the error definitions, to make the resulting code more readable. Sadly enums are 3.4+ only.
python-mpd2 is python3.6+.
Oh and I think we could include the error definitions, to make the resulting code more readable. Sadly enums are 3.4+ only.
python-mpd2 is python3.6+.
Ah right. Would yo mind if i squash them into __init__.py
then? Like from mpd import errors
, where errors would be the enum.
Oh and I think we could include the error definitions, to make the resulting code more readable. Sadly enums are 3.4+ only.
python-mpd2 is python3.6+.
Ah right. Would yo mind if i squash them into
__init__.py
then? Likefrom mpd import errors
, where errors would be the enum.
go ahead.
Is there anything missing or can this be merged and released?
Looks good to me. @mweinelt can merge this if he thinks it's ready.
ping @mweinelt
This allows for improved error handling based on error numbers, offsets in a command list, command and ultimately also hands you the literal error message.
The whole story is, that a home-assistant user came forward complainig about the noise from
albumart
commands that returnedfor every song, that didn't have any. There is currently no clean way to ignore specific errors, but to rely on string matching. Instead of everyone doing that for themselves I believe a simple pattern like this might be useful.