Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ErrorInformant.php
1<?php
2
4
7
9{
10 protected ?int $code;
11 protected int $httpStatus;
12 protected ?string $message;
13 protected ?string $moreInfo;
14
20 public function __construct(?string $message, ?int $code, ?string $moreInfo, int $httpStatus)
21 {
22 $this->code = $code;
23 $this->message = $message;
24 $this->moreInfo = $moreInfo;
25 $this->httpStatus = $httpStatus;
26 }
27
28 public function getError(): Error
29 {
30 return new Error($this->getErrorMessage(), $this->code ?? 0);
31 }
32
33 protected function getErrorMessage(): string
34 {
35
36 $str = Loc::getMessage('MESSAGESERVICE_PROVIDER_TWILIO_ERROR_INFORMANT_ERROR', [
37 '#BR#' => '<br>',
38 ]);
39
40 if (isset($this->moreInfo))
41 {
42 $str .= Loc::getMessage('MESSAGESERVICE_PROVIDER_TWILIO_ERROR_INFORMANT_ERROR_MORE', [
43 '#LINKSTART#' => '<a href="' . $this->moreInfo . '" target="_blank">',
44 '#INFO#' => $this->moreInfo,
45 '#LINKEND#' => '</a>',
46 ]);
47
48 return $str;
49 }
50
51 if (isset($this->message, $this->code))
52 {
53 $str .= Loc::getMessage('MESSAGESERVICE_PROVIDER_TWILIO_ERROR_INFORMANT_ERROR_CODE', [
54 '#CODE#' => $this->code,
55 '#MESSAGE#' => $this->message,
56 ]);
57
58 return $str;
59 }
60
61 $str .= Loc::getMessage('MESSAGESERVICE_PROVIDER_TWILIO_ERROR_INFORMANT_ERROR_HTTP_STATUS', [
62 '#STATUS#' => $this->httpStatus,
63 ]);
64
65 return $str;
66 }
67}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
__construct(?string $message, ?int $code, ?string $moreInfo, int $httpStatus)