Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: raise UsageError #165

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion silverback/cluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from apepay import Stream, StreamManager
from pydantic import computed_field

from silverback.exceptions import ClientError
from silverback.version import version

from .types import (
Expand Down Expand Up @@ -54,7 +55,7 @@ def render_error(error: dict):
else:
message = response.text

raise RuntimeError(message)
raise ClientError(message)

response.raise_for_status()

Expand Down
5 changes: 5 additions & 0 deletions silverback/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any

import click
from ape.exceptions import ApeException

from .types import TaskType
Expand Down Expand Up @@ -41,6 +42,10 @@ def __init__(self, *exceptions: Exception | str):
super().__init__("Startup failure(s) detected. See logs for details.")


class ClientError(SilverbackException, click.UsageError):
fubuloubu marked this conversation as resolved.
Show resolved Hide resolved
"""Exception for client errors in the HTTP request."""


class NoTasksAvailableError(SilverbackException):
def __init__(self):
super().__init__("No tasks to execute")
Expand Down
Loading