From cd224d98cae2ae87cf49ed1e058bb997f07e6c52 Mon Sep 17 00:00:00 2001 From: Scott Gigante Date: Tue, 23 Jul 2024 11:27:58 -0400 Subject: [PATCH] Raise HealthCheckException directly from BaseStorageBackend.check_status Currently, all HealthCheckExceptions are raised as "unknown exception" from the storage healthcheck, even if they are, indeed, known exceptions. This PR fixes that. --- health_check/storage/backends.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/health_check/storage/backends.py b/health_check/storage/backends.py index ec58f8b8..4f61896c 100644 --- a/health_check/storage/backends.py +++ b/health_check/storage/backends.py @@ -10,7 +10,7 @@ from django.core.files.storage import get_storage_class from health_check.backends import BaseHealthCheckBackend -from health_check.exceptions import ServiceUnavailable +from health_check.exceptions import HealthCheckException, ServiceUnavailable class StorageHealthCheck(BaseHealthCheckBackend): @@ -75,6 +75,8 @@ def check_status(self): file_name = self.check_save(file_name, file_content) self.check_delete(file_name) return True + except HealthCheckException: + raise except Exception as e: raise ServiceUnavailable("Unknown exception") from e