From ee9b4f15c6334e64ed8d844297ac2c7eb4ef6f83 Mon Sep 17 00:00:00 2001 From: "Mees, T.D. (Ty)" Date: Fri, 1 Nov 2024 13:49:20 +0100 Subject: [PATCH] fix: stop invalid uptime from crashing tha page --- humitifier-server/src/hosts/templatetags/host_tags.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/humitifier-server/src/hosts/templatetags/host_tags.py b/humitifier-server/src/hosts/templatetags/host_tags.py index 4d545fe..bf5dcff 100644 --- a/humitifier-server/src/hosts/templatetags/host_tags.py +++ b/humitifier-server/src/hosts/templatetags/host_tags.py @@ -20,6 +20,9 @@ def size_from_mb(value, **kwargs): @register.filter() def uptime(time_in_seconds: float, reference: datetime): - startup_datetime = reference - timedelta(seconds=time_in_seconds) + try: + startup_datetime = reference - timedelta(seconds=time_in_seconds) + except TypeError: + return "Failed to parse uptime" return timesince(startup_datetime, reference) \ No newline at end of file