diff --git a/src/cockpit/router.py b/src/cockpit/router.py index 737f33df7e7..526910b7437 100644 --- a/src/cockpit/router.py +++ b/src/cockpit/router.py @@ -20,7 +20,7 @@ from typing import Dict, List, Optional from .jsonutil import JsonDocument, JsonObject -from .protocol import CockpitProtocolError, CockpitProtocolServer +from .protocol import CockpitProblem, CockpitProtocolError, CockpitProtocolServer logger = logging.getLogger(__name__) @@ -104,10 +104,8 @@ def shutdown_endpoint(self, _msg: 'JsonObject | None' = None, **kwargs: JsonDocu self.router.shutdown_endpoint(self, _msg, **kwargs) -class RoutingError(Exception): - def __init__(self, problem, **kwargs): - self.problem = problem - self.kwargs = kwargs +class RoutingError(CockpitProblem): + pass class RoutingRule: @@ -194,7 +192,7 @@ def channel_control_received(self, channel: str, command: str, message: JsonObje logger.debug('Trying to find endpoint for new channel %s payload=%s', channel, message.get('payload')) endpoint = self.check_rules(message) except RoutingError as exc: - self.write_control(command='close', channel=channel, problem=exc.problem, **exc.kwargs) + self.write_control(exc.attrs, command='close', channel=channel) return self.open_channels[channel] = endpoint