From 507cf9edd1046b87914bcb82adbf165e0d3caef0 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Thu, 25 Jul 2019 16:05:06 +0100 Subject: [PATCH] Added more descriptive error messages --- .../controller/ObservationsController.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/ObservationsController.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/ObservationsController.kt index 1d95d04..0c668d0 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/ObservationsController.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/controller/ObservationsController.kt @@ -285,11 +285,12 @@ class ObservationsController { if (::mailer.isInitialized) { val data = getObservations(observationsRequest) if (data.isEmpty()) - return false + throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Request would send no data.") mailer.sendObservationData(data) return true - } else + } else { logger.error("Mailer has not been initialized.") - return false + throw ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "Mail is currently unavailable due to a server configuration error.") + } } } \ No newline at end of file