original_string: protected function encodeException($exception, ResponseInterface $response, $status = 500)
      {
          $error = ['message' => $exception->getMessage(), 'type' => get_class($exception)];
  
          if ($this->getDisplayErrorDetails()) {
              $error['exception'] = [];
  
              do {
                  $error['exception'][] = [
                      'type' => get_class($exception),
                      'code' => $exception->getCode(),
                      'message' => $exception->getMessage(),
                      'file' => $exception->getFile(),
                      'line' => $exception->getLine(),
                      'trace' => explode("\n", $exception->getTraceAsString()),
                  ];
              } while ($exception = $exception->getPrevious());
          }
  
          return $response->write(json_encode($error))->withStatus($status);
      }
code: protected function encodeException($exception, ResponseInterface $response, $status = 500)
      {
          $error = ['message' => $exception->getMessage(), 'type' => get_class($exception)];
  
          if ($this->getDisplayErrorDetails()) {
              $error['exception'] = [];
  
              do {
                  $error['exception'][] = [
                      'type' => get_class($exception),
                      'code' => $exception->getCode(),
                      'message' => $exception->getMessage(),
                      'file' => $exception->getFile(),
                      'line' => $exception->getLine(),
                      'trace' => explode("\n", $exception->getTraceAsString()),
                  ];
              } while ($exception = $exception->getPrevious());
          }
  
          return $response->write(json_encode($error))->withStatus($status);
      }
code_tokens: protected function encodeException ( $ exception , ResponseInterface $ response , $ status = 500 ) { $ error = [ 'message' => $ exception -> getMessage ( ) , 'type' => get_class ( $ exception ) ] ; if ( $ this -> getDisplayErrorDetails ( ) ) { $ error [ 'exception' ] = [ ] ; do { $ error [ 'exception' ] [ ] = [ 'type' => get_class ( $ exception ) , 'code' => $ exception -> getCode ( ) , 'message' => $ exception -> getMessage ( ) , 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , 'trace' => explode ( "\n" , $ exception -> getTraceAsString ( ) ) , ] ; } while ( $ exception = $ exception -> getPrevious ( ) ) ; } return $ response -> write ( json_encode ( $ error ) ) -> withStatus ( $ status ) ; }
docstring: Encode and return exception.
  
  @param  Throwable|Exception $exception
  @param  ResponseInterface   $response
  @param  int                 $status
  @return ResponseInterface
docstring_tokens: Encode and return exception .