Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| common_exception_RestApi | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getUserMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2017 (original work) Open Assessment Technologies SA ; |
| 19 | */ |
| 20 | |
| 21 | /** |
| 22 | * Class common_exception_RestApi |
| 23 | * Note: Exception message is supposed to be shown to the end user. |
| 24 | * @author Aleh Hutnikau, <hutnikau@1pt.com> |
| 25 | */ |
| 26 | class common_exception_RestApi extends common_exception_ClientException |
| 27 | { |
| 28 | protected $userMessage; |
| 29 | |
| 30 | /** |
| 31 | * common_exception_RestApi constructor. |
| 32 | * @param null $message |
| 33 | * @param int $code |
| 34 | */ |
| 35 | public function __construct($message = null, $code = 0) |
| 36 | { |
| 37 | parent::__construct($message, $code); |
| 38 | $this->userMessage = $message; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get the human-readable message for the end-user. It is supposed |
| 43 | * to be translated and does not contain any confidential information |
| 44 | * about the system and its sensitive data. |
| 45 | * |
| 46 | * @return string A human-readable message. |
| 47 | */ |
| 48 | public function getUserMessage() |
| 49 | { |
| 50 | if ($this->userMessage === null) { |
| 51 | return __("Wrong request type, try again please or contact your system administrator"); |
| 52 | } else { |
| 53 | return $this->userMessage; |
| 54 | } |
| 55 | } |
| 56 | } |