-
Notifications
You must be signed in to change notification settings - Fork 15
/
DpdException.php
49 lines (43 loc) · 1.18 KB
/
DpdException.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace DPDBenelux\Shipping;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Phrase;
class DpdException extends LocalizedException
{
private $exceptionMessage;
/**
* @param Phrase|string $message
* @param int $code
* @param null $previous
*/
// @codingStandardsIgnoreStart
public function __construct($message, $code = 0, $previous = null)
{
$message = $this->getMessageString($message);
// @codingStandardsIgnoreLine
$this->exceptionMessage = __($message);
if ($code !== 0) {
$code = (string) $code;
$this->code = $code;
$message = '[' . $code . '] ' . $message;
}
if (is_string($message)) {
// @codingStandardsIgnoreLine
$message = __($message);
}
parent::__construct($message, $previous);
}
// @codingStandardsIgnoreEnd
/**
* @param $message
*
* @return string
*/
private function getMessageString($message)
{
if ($message instanceof Phrase) {
return $message->render();
}
return $message;
}
}