public function testCatchException() { $message = 'Test catchException()'; try { throw new \Exception($message); } catch (\Exception $e) { $this->_exceptionHandler->catchException($e); } finally { $errorArray = IController::getErrorArray(); $errorIndex = count($errorArray) - 1; $errorArray = $errorArray[$errorIndex]; $this->assertEquals($errorArray['message'], $message); } }
/** * Returns formated error array * * @return array */ private function loadLogDisplay() : array { $array = array(); $count = 1; foreach (IController::getErrorArray() as $value) { $array[] = "#{$count} [{$value['type']}]"; $array[] = " {$value['message']} in {$value['file']} " . "on line {$value['line']}"; ++$count; if (!empty($value['trace'])) { $array[] = " [Backtrace]:"; foreach ($value['trace'] as $trace) { $message = str_replace("\n", "\n ", $trace['message']); $array[] = " {$message}"; $array[] = " IN: {$trace['file']}"; $array[] = " ARGUMENTS:"; $array[] = " " . str_replace("\n", "\n ", $trace['arguments']); } } $array[] = "\n"; } return array('errors' => implode("\n", $array), 'errorsCount' => $count - 1); }
private function getErrorArray() { $errorArray = IController::getErrorArray(); $errorIndex = count($errorArray) - 1; return $errorArray[$errorIndex]; }
/** * @return array */ private function getErrorArray() : array { return IController::getErrorArray(); }