3 namespace Shaarli\Updater\Exception
;
8 * Class UpdaterException.
10 class UpdaterException
extends Exception
13 * @var string Method where the error occurred.
18 * @var Exception The parent exception.
25 * @param string $message Force the error message if set.
26 * @param string $method Method where the error occurred.
27 * @param Exception|bool $previous Parent exception.
29 public function __construct($message = '', $method = '', $previous = false)
31 $this->method
= $method;
32 $this->previous
= $previous;
33 $this->message
= $this->buildMessage($message);
37 * Build the exception error message.
39 * @param string $message Optional given error message.
41 * @return string The built error message.
43 private function buildMessage($message)
46 if (!empty($message)) {
47 $out .= $message . PHP_EOL
;
50 if (!empty($this->method
)) {
51 $out .= t('An error occurred while running the update ') . $this->method
. PHP_EOL
;
54 if (!empty($this->previous
)) {
55 $out .= ' ' . $this->previous
->getMessage();