From d6962fe04580a2c2f422a949e5e9e86fbcfbf66f Mon Sep 17 00:00:00 2001 From: Anton Bagliy <taccessviolation@gmail.com> Date: Tue, 25 Sep 2018 18:34:36 +0300 Subject: [PATCH] FIX: better error messages when failing to change rates close #312 --- .../classes/Controller/Handler/Rating.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Handler/Rating.php b/~dev_rating/application/classes/Controller/Handler/Rating.php index a69542356..1878c115f 100644 --- a/~dev_rating/application/classes/Controller/Handler/Rating.php +++ b/~dev_rating/application/classes/Controller/Handler/Rating.php @@ -29,10 +29,16 @@ class Controller_Handler_Rating extends Controller_Handler $_POST['submoduleID'], $_POST['rate'] ); - if (!is_null($error)) - throw HTTP_Exception::factory($error['code'], $error['message']); - - $this->response->body(json_encode([ 'success' => true ])); + if (!is_null($error)) { + if (!is_null($error['message'])) { + $this->response->body(json_encode(['success' => false, 'message' => $error['message']])); + $this->response->status(400); + } else { + throw HTTP_Exception::factory($error['code'], $error['message']); + } + } else { + $this->response->body(json_encode(['success' => true])); + } } public function action_SetExamPeriodOption() { -- GitLab