irongit

Enhanced time synchronization for drf views.

better exceptions

huncholanehuncholaneauthored
parent 900bdd2commit 8dda8b77c03253ed231406af3263e46131c4a798Browse files

2 files changed, +8 -5

+7-5plusrequest/exceptions.py
@@ -5,7 +5,8 @@ from rest_framework import exceptions
55 class InvalidServerDatetimeField(exceptions.APIException):
66 def __init__(self, field_name: str, val: Any, code: str | int):
77 super().__init__(
8- f"{field_name} is not a valid datetime. {val} is a {type(val)}", str(code)
8+ f"InvalidServerDatetimeField: {field_name} is not a valid datetime. {val} is a {type(val)}",
9+ str(code),
910 )
1011
1112
@@ -13,7 +14,7 @@ class InvalidClientDatetimeField(exceptions.APIException):
1314 def __init__(self, field_name: str, val: str, fmt: str, code: str | int):
1415 code = str(code)
1516 super().__init__(
16- f"{field_name} header {val} val is unable to be parsed with {fmt}",
17+ f"InvalidClientDatetimeField: {field_name} header {val} val is unable to be parsed with {fmt}",
1718 code,
1819 )
1920
@@ -23,9 +24,10 @@ class NoUpdate(exceptions.APIException):
2324 code = str(code)
2425 if request_method in ["POST", "PUT"]:
2526 super().__init__(
26- "Client has submitted older data than the server. Skipping update", code
27+ "NoUpdate: Client has submitted older data than the server. Skipping update",
28+ code,
2729 )
2830 elif request_method == "GET":
29- super().__init__("Client is already up to date", code)
31+ super().__init__("NoUpdate: Client is already up to date", code)
3032 else:
31- super().__init__("No update", code)
33+ super().__init__("NoUpdate", code)
+1-0plusrequest/request.py
@@ -23,3 +23,4 @@ class PlusRequest(Request, HttpRequest):
2323 ...
2424 return Response(data)
2525 ```"""
26+ return TimestampOp(self)