diff --git a/core/Exceptions/HtmlMessageException.php b/core/Exceptions/HtmlMessageException.php index 243a0f1726f7eedec43964f7c7219f900cdf40e2..69f809e1e0c51fdc11421cafba93ca09a4183fd3 100644 --- a/core/Exceptions/HtmlMessageException.php +++ b/core/Exceptions/HtmlMessageException.php @@ -16,15 +16,7 @@ use Exception; * * @api */ -class HtmlMessageException extends Exception +class HtmlMessageException extends Exception implements HtmlMessageExceptionInterface { - /** - * Returns the exception message. - * - * @return string - */ - public function getHtmlMessage() - { - return $this->getMessage(); - } + // empty } \ No newline at end of file diff --git a/core/Exceptions/HtmlMessageExceptionInterface.php b/core/Exceptions/HtmlMessageExceptionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..b96c2e0a84dd28b3b6935a69e34b3e3e2a5fdca3 --- /dev/null +++ b/core/Exceptions/HtmlMessageExceptionInterface.php @@ -0,0 +1,20 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Exceptions; + +/** + * Exceptions that implement this interface are assumed to have HTML content + * in their messages. + * + * @api + */ +interface HtmlMessageExceptionInterface +{ + // empty +} \ No newline at end of file diff --git a/core/FrontController.php b/core/FrontController.php index 6f101c10acfcc91b94b98f5cbe312ccf6d71b1b4..e61e37d21d7e952c0bbc8d19a930f4c7ec42df73 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -13,6 +13,7 @@ use Exception; use Piwik\API\Request; use Piwik\API\ResponseBuilder; use Piwik\Exceptions\HtmlMessageException; +use Piwik\Exceptions\HtmlMessageExceptionInterface; use Piwik\Http\Router; use Piwik\Plugin\Controller; use Piwik\Plugin\Report; @@ -613,8 +614,8 @@ class FrontController extends Singleton { $debugTrace = $ex->getTraceAsString(); - if (method_exists($ex, 'getHtmlMessage')) { - $message = $ex->getHtmlMessage(); + if ($ex instanceof HtmlMessageExceptionInterface) { + $message = $ex->getMessage(); } else { $message = Common::sanitizeInputValue($ex->getMessage()); }