From cf7690a60f23bbaee363ad15f0415384bf6f037e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 28 Dec 2020 10:45:34 +0200 Subject: [PATCH] Remove usages of EtebaseValidationError. --- etebase_fastapi/authentication.py | 2 +- etebase_fastapi/stoken_handler.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/etebase_fastapi/authentication.py b/etebase_fastapi/authentication.py index 902b79b..a13cc51 100644 --- a/etebase_fastapi/authentication.py +++ b/etebase_fastapi/authentication.py @@ -298,7 +298,7 @@ def signup_save(data: SignupIn, request: Request) -> User: except django_exceptions.ValidationError as e: transform_validation_error("user", e) except Exception as e: - raise EtebaseValidationError("generic", str(e)) + raise HttpError("generic", str(e)) if hasattr(instance, "userinfo"): raise HttpError("user_exists", "User already exists", status_code=status.HTTP_409_CONFLICT) diff --git a/etebase_fastapi/stoken_handler.py b/etebase_fastapi/stoken_handler.py index a976830..76d348a 100644 --- a/etebase_fastapi/stoken_handler.py +++ b/etebase_fastapi/stoken_handler.py @@ -3,9 +3,10 @@ import typing as t from django.db.models import QuerySet from fastapi import status -from django_etebase.exceptions import EtebaseValidationError from django_etebase.models import Stoken +from .exceptions import HttpError + # TODO missing stoken_annotation type StokenAnnotation = t.Any @@ -15,7 +16,7 @@ def get_stoken_obj(stoken: t.Optional[str]) -> t.Optional[Stoken]: try: return Stoken.objects.get(uid=stoken) except Stoken.DoesNotExist: - raise EtebaseValidationError("bad_stoken", "Invalid stoken.", status_code=status.HTTP_400_BAD_REQUEST) + raise HttpError("bad_stoken", "Invalid stoken.", status_code=status.HTTP_400_BAD_REQUEST) return None