Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
Error.php
1
<?php
2
3
namespace
Bitrix\Im\V2
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
7
class
Error
extends
\Bitrix\Main\Error
8
{
9
public
const
NOT_FOUND
=
'NOT_FOUND'
;
10
11
protected
string
$description
=
''
;
12
13
public
function
__construct
(
string
$code
, ...$args)
14
{
15
$message
=
null
;
16
$description
=
null
;
17
$customData
= [];
18
19
if
(!empty($args))
20
{
21
$message
= isset($args[0]) && is_string($args[0]) ? $args[0] :
null
;
22
$description
= isset($args[1]) && is_string($args[1]) ? $args[1] :
null
;
23
$inx = count($args) - 1;
24
$customData
= isset($args[$inx]) && is_array($args[$inx]) ? $args[$inx] : [];
25
}
26
27
$replacements = [];
28
foreach
(
$customData
as $key => $value)
29
{
30
$replacements[
"#{$key}#"
] = $value;
31
}
32
33
if
(!is_string(
$message
))
34
{
35
$message
= $this->
loadErrorMessage
($code, $replacements);
36
}
37
38
if
(is_string(
$message
) && mb_strlen(
$message
) > 0 && !is_string(
$description
))
39
{
40
$description
= $this->
loadErrorDescription
($code, $replacements);
41
}
42
43
if
(!is_string(
$message
) || mb_strlen(
$message
) === 0)
44
{
45
$message
=
$code
;
46
}
47
48
parent::__construct(
$message
,
$code
,
$customData
);
49
50
if
(is_string(
$description
))
51
{
52
$this->
setDescription
($description);
53
}
54
}
55
56
public
function
getDescription
(): string
57
{
58
return
$this->description
;
59
}
60
61
public
function
setDescription
(
string
$description
): void
62
{
63
$this->description =
$description
;
64
}
65
66
protected
function
loadErrorMessage
(
$code
, $replacements): string
67
{
68
return
Loc::getMessage
(
"ERROR_{$code}"
, $replacements) ??
''
;
69
}
70
71
protected
function
loadErrorDescription
(
$code
, $replacements): string
72
{
73
return
Loc::getMessage
(
"ERROR_{$code}_DESC"
, $replacements) ??
''
;
74
}
75
}
Bitrix\Im\V2\Error
Definition
Error.php:8
Bitrix\Im\V2\Error\$description
string $description
Definition
Error.php:11
Bitrix\Im\V2\Error\getDescription
getDescription()
Definition
Error.php:56
Bitrix\Im\V2\Error\setDescription
setDescription(string $description)
Definition
Error.php:61
Bitrix\Im\V2\Error\NOT_FOUND
const NOT_FOUND
Definition
Error.php:9
Bitrix\Im\V2\Error\__construct
__construct(string $code,... $args)
Definition
Error.php:13
Bitrix\Im\V2\Error\loadErrorMessage
loadErrorMessage($code, $replacements)
Definition
Error.php:66
Bitrix\Im\V2\Error\loadErrorDescription
loadErrorDescription($code, $replacements)
Definition
Error.php:71
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Error\$code
$code
Definition
error.php:16
Bitrix\Main\Error\$message
$message
Definition
error.php:19
Bitrix\Main\Error\$customData
$customData
Definition
error.php:23
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Im\V2
Definition
ActionUuid.php:3
modules
im
lib
V2
Error.php
Создано системой
1.10.0