/**
  * @param Exception $ex
  */
 public function handleException(Exception $ex)
 {
     $trace = $ex->getTrace();
     foreach ($trace as &$item) {
         foreach (array_keys($item) as $key) {
             if (!array_contains(['file', 'line', 'function', 'class'], $key)) {
                 array_remove($item, $key);
             }
         }
     }
     $response = new JsonResponse(HttpStatusCode::INTERNAL_SERVER_ERROR);
     $response->getData()->set('error.message', $ex->getMessage());
     $response->getData()->set('error.code', $ex->getCode());
     $response->getData()->set('error.file', $ex->getFile());
     $response->getData()->set('error.line', $ex->getLine());
     $response->getData()->set('error.trace', $trace);
     $this->httpApp->shutdownWithResponse($response);
 }
 function it_handles_exception(IHttpApp $httpApp, Exception $ex)
 {
     $httpApp->shutdownWithResponse(Argument::type(JsonResponse::class))->shouldBeCalled();
     $this->handleException($ex);
 }