/**
  * Handle uncaught exception and throwables for the system by logging information and displaying a generic notice
  * to the user so that they are informed of an error without exposing information that could be used for an attack.
  *
  * @param \Throwable $uncaught A throwable that was not caught in the system.
  *
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function handler(\Throwable $uncaught)
 {
     trigger_error($uncaught->getMessage(), E_USER_WARNING);
     $currentBuffer = (string) $this->writer;
     if (!empty($currentBuffer)) {
         trigger_error('Buffer needs to be flushed in exception handler for clean error page.  Buffer was: ' . $currentBuffer, E_USER_WARNING);
         $this->writer->flush();
     }
     $this->writer->writeStart();
     $this->writer->write(['head', [], [['title', [], ['Internal Error']]]]);
     if (isset($this->viewThrowable)) {
         $this->viewThrowable->set($uncaught);
         $this->writer->write(['body', [], [['h1', [], 'Internal Error'], $this->viewThrowable->get()]]);
     } else {
         $this->writer->write(['body', [], [['h1', [], 'Internal Error'], ['p', [], 'We are sorry about this error, the administrator has been notified and we will fix this issue as soon as possible.  Please contact us for more information.']]]);
     }
     $this->writer->writeEnd();
     $this->response->setStatus(500);
     $this->response->setBody((string) $this->writer);
     $this->response->send();
 }
 /**
  * Handle the shutdown of the system, recording any fatal errors.
  */
 public function handler()
 {
     $err = error_get_last();
     if (!isset($err['type']) || !in_array($err['type'], [E_USER_ERROR, E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING])) {
         return;
     }
     $this->viewMessageBox->setTitle('Fatal Error');
     $this->viewMessageBox->addContent(['p', ['class' => 'Description'], 'This is an error that we were unable to handle.  Please tell us any information that could help us ' . 'avoid this error in the future.  Useful information such as the date, time and what you were doing ' . 'when the error occurred should help us fix this.']);
     if (!empty($this->email)) {
         $this->viewMessageBox->addContent(['div', ['class' => 'Contact'], 'Contact: ' . $this->email]);
     }
     if ($this->showError) {
         $this->viewError->set($err);
         $this->viewMessageBox->addContent($this->viewError->get());
     }
     $this->writer->write($this->viewMessageBox->get());
     $this->response->setStatus(500);
     $this->response->setBody((string) $this->writer);
     $this->response->send();
 }