From 5988457253a270607e22428ba68fe752ed7c6075 Mon Sep 17 00:00:00 2001 From: Daniel Waxweiler Date: Wed, 3 Apr 2024 22:43:49 +0200 Subject: [PATCH] return status code in error cases too --- source/includes/Api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/includes/Api.php b/source/includes/Api.php index a21449f..a99b0fb 100644 --- a/source/includes/Api.php +++ b/source/includes/Api.php @@ -44,9 +44,9 @@ class Api { } return $events; } catch (GeneralException $e) { - return 'The events could not be loaded!'; + return new \WP_Error('events_not_loading', 'The events could not be loaded!', array('status' => 500)); } catch (GroupNotFoundException $e) { - return sprintf('The group "%s" could not be found!', $groupName); + return new \WP_Error('group_not_found', sprintf('The group "%s" could not be found!', $groupName), array('status' => 404)); } } }