| Total Complexity | 7 |
| Total Lines | 27 |
| Duplicated Lines | 0 % |
| Coverage | 77.78% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class midcom_error_midgard extends midcom_error |
||
| 18 | { |
||
| 19 | 31 | public function __construct(mgd_exception $e, $id) |
|
| 20 | { |
||
| 21 | 31 | if ($id !== null) { |
|
| 22 | 31 | if ($e->getCode() === MGD_ERR_NOT_EXISTS) { |
|
| 23 | 19 | $code = MIDCOM_ERRNOTFOUND; |
|
| 24 | 19 | $message = "The object with identifier {$id} was not found."; |
|
| 25 | 14 | } elseif ($e->getCode() == MGD_ERR_ACCESS_DENIED) { |
|
| 26 | $code = MIDCOM_ERRFORBIDDEN; |
||
| 27 | $message = midcom::get()->i18n->get_string('access denied', 'midcom'); |
||
| 28 | 14 | } elseif ($e->getCode() == MGD_ERR_OBJECT_DELETED) { |
|
| 29 | $code = MIDCOM_ERRNOTFOUND; |
||
| 30 | $message = "The object with identifier {$id} was deleted."; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | //If other options fail, go for the server error |
||
| 34 | 31 | if (!isset($code)) { |
|
| 35 | 14 | $code = MIDCOM_ERRCRIT; |
|
| 36 | 14 | $message = $e->getMessage(); |
|
| 37 | } |
||
| 38 | 31 | parent::__construct($message, $code); |
|
|
|
|||
| 39 | 31 | } |
|
| 40 | |||
| 41 | 21 | public function log(int $loglevel = MIDCOM_LOG_WARN) |
|
| 44 | } |
||
| 45 | } |