/**
  * Create an error response for any exception thrown while creating this email
  *
  * @param \Exception $e
  *
  */
 protected function setErrorResponse(\Exception $e)
 {
     if ($e instanceof ControllerException) {
         $result = $e->getErrorType();
     } else {
         $result = 'genericError';
     }
     WikiaLogger::instance()->error('Error while sending email', ['result' => $result, 'msg' => $e->getMessage()]);
     $this->hasErrorResponse = true;
     $this->response->setData(['result' => $result, 'msg' => $e->getMessage()]);
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function handleException(\Exception $e)
 {
     $refl = new \ReflectionClass($e);
     if ($e instanceof HttpExceptionInterface) {
         $title = sprintf('%s::%s', $refl->getShortName(), $e->getErrorType());
         $detail = $e->getMessage();
         $status = $e->getHttpCode();
     } else {
         $title = $refl->getShortName();
         $detail = 'Oh no! Something bad happened on the server! Please try again.';
         $status = 500;
     }
     $serialized = $this->getSerializer()->serializeError($title, $detail, $status);
     $payload = new Rest\RestPayload($serialized);
     return $this->createRestResponse($status, $payload);
 }