Piwik\Plugins\API\Renderer\Php::renderException PHP Method

renderException() public method

public renderException ( $message, Exception | Throwable $exception ) : string
$message
$exception Exception | Throwable
return string
    public function renderException($message, $exception)
    {
        $message = array('result' => 'error', 'message' => $message);
        return $this->serializeIfNeeded($message);
    }

Usage Example

Example #1
0
 public function test_renderException_shouldReturnTheMessageAndNotTheExceptionMessage()
 {
     $response = $this->builder->renderException('This message should be ignored', new \BadMethodCallException('The other message'));
     $expected = array('result' => 'error', 'message' => 'This message should be ignored');
     $this->assertEquals($expected, $response);
 }