Skip to content

Commit

Permalink
rename SnackbarException -> SnackbarError
Browse files Browse the repository at this point in the history
  • Loading branch information
ckcollab committed Jun 15, 2023
1 parent 985500b commit 975a4f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,21 @@ if SLACK_WEBHOOK_URL:
```
#### `SnackbarException`
#### `SnackbarError`
A little helper that when raised returns a JSON response to the user with a
snackbar message. This message is automatically rendered as a snackbar by
Skeletor.
```py
# views.py
from ckc.exceptions import SnackbarException
from ckc.exceptions import SnackbarError
class TestExceptionsViewSet(APIView):
def get(self, request, *args, **kwargs):
# This will return {"snackbar_message": "Something went wrong"}
raise SnackbarException("Something went wrong")
raise SnackbarError("Something went wrong")
```
#### `./manage.py` commands
Expand Down
2 changes: 1 addition & 1 deletion ckc/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework.exceptions import ValidationError


class SnackbarException(ValidationError):
class SnackbarError(ValidationError):
def __init__(self, message):
super().__init__({'snackbar_message': message})
4 changes: 2 additions & 2 deletions testproject/testapp/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from rest_framework.views import APIView

from ckc.exceptions import SnackbarException
from ckc.exceptions import SnackbarError


class TestExceptionsViewSet(APIView):
def get(self, request, *args, **kwargs):
raise SnackbarException('This is a test exception')
raise SnackbarError('This is a test exception')

0 comments on commit 975a4f4

Please sign in to comment.