From 68eeb2a2a9eb95079076ceef62336e406d3f636c Mon Sep 17 00:00:00 2001 From: kaliko Date: Sun, 10 Mar 2024 17:53:03 +0100 Subject: [PATCH] Fixed wrong exception name --- mpdaio/client.py | 2 +- mpdaio/utils.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mpdaio/client.py b/mpdaio/client.py index aaffc0a..c46aa74 100644 --- a/mpdaio/client.py +++ b/mpdaio/client.py @@ -426,7 +426,7 @@ class CmdHandler: async def _fetch_nothing(self): line = await self._read_line() if line is not None: - raise ProtocolError(f"Got unexpected return value: '{line}'") + raise MPDProtocolError(f"Got unexpected return value: '{line}'") async def _fetch_item(self): pairs = [_ async for _ in self._read_pairs()] diff --git a/mpdaio/utils.py b/mpdaio/utils.py index 1d01db5..723cd50 100644 --- a/mpdaio/utils.py +++ b/mpdaio/utils.py @@ -2,6 +2,8 @@ # SPDX-FileCopyrightText: 2012-2024 kaliko # SPDX-License-Identifier: LGPL-3.0-or-later +from .exceptions import MPDCommandError + class Range: def __init__(self, tpl): @@ -22,26 +24,26 @@ class Range: try: return str(int(item)) except (TypeError, ValueError) as err: - raise CommandError(f'Not an integer: "{item}"') from err + raise MPDCommandError(f'Not an integer: "{item}"') from err return item def _check(self): if not isinstance(self.tpl, tuple): - raise CommandError('Wrong type, provide a tuple') + raise MPDCommandError('Wrong type, provide a tuple') if len(self.tpl) == 0: return if len(self.tpl) == 1: self.lower = self._check_element(self.tpl[0]) return if len(self.tpl) != 2: - raise CommandError('Range wrong size (0, 1 or 2 allowed)') + raise MPDCommandError('Range wrong size (0, 1 or 2 allowed)') self.lower = self._check_element(self.tpl[0]) self.upper = self._check_element(self.tpl[1]) if self.lower == '' and self.upper != '': - raise CommandError(f'Integer expected to start the range: {self.tpl}') + raise MPDCommandError(f'Integer expected to start the range: {self.tpl}') if self.upper.isdigit() and self.lower.isdigit(): if int(self.lower) > int(self.upper): - raise CommandError(f'Wrong range: {self.lower} > {self.upper}') + raise MPDCommandError(f'Wrong range: {self.lower} > {self.upper}') def escape(text): return text.replace("\\", "\\\\").replace('"', '\\"') -- 2.39.2