Ejemplo n.º 1
0
 /**
  * Test constructor
  */
 public function testEmptyConstructor()
 {
     $exception = new JsonRpcException();
     $this->assertEquals(JsonRpcException::CODE_UNKNOWN_ERROR, $exception->getCode());
     $this->assertEquals(JsonRpcException::getErrorMessage($exception->getCode()), $exception->getMessage());
     $this->assertNull($exception->getData());
     $this->assertNull($exception->getPrevious());
 }
Ejemplo n.º 2
0
 /**
  * @param \JsonRpc\Base\JsonRpcException $exception
  */
 protected function respondError(JsonRpcException $exception)
 {
     $response = ['jsonrpc' => self::JSONRPC_VERSION, 'error' => ['code' => $exception->getCode(), 'message' => $exception->getMessage()], 'id' => $this->_id];
     $data = $exception->getData();
     if ($data !== null) {
         $response['error']['data'] = $data;
     }
     if (ob_get_level()) {
         ob_end_clean();
     }
     $this->_transport->respond($response, $exception->getCode(), $this->headers);
 }