Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
error.php
1<?php
9namespace Bitrix\Main;
10
11use Throwable;
12
13class Error implements \JsonSerializable
14{
16 protected $code;
17
19 protected $message;
23 protected $customData;
24
33 public function __construct($message, $code = 0, $customData = null)
34 {
35 $this->message = $message;
36 $this->code = $code;
37 $this->customData = $customData;
38 }
39
44 public static function createFromThrowable(Throwable $exception): static
45 {
46 return new static($exception->getMessage(), $exception->getCode());
47 }
48
53 public function getCode()
54 {
55 return $this->code;
56 }
57
62 public function getMessage()
63 {
64 return $this->message;
65 }
66
70 public function getCustomData()
71 {
72 return $this->customData;
73 }
74
75 public function __toString()
76 {
77 return $this->getMessage();
78 }
79
87 #[\ReturnTypeWillChange]
88 public function jsonSerialize()
89 {
90 return [
91 'message' => $this->getMessage(),
92 'code' => $this->getCode(),
93 'customData' => $this->getCustomData(),
94 ];
95 }
96}
static createFromThrowable(Throwable $exception)
Definition error.php:44
__construct($message, $code=0, $customData=null)
Definition error.php:33