-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCouldNotProcessData.php
More file actions
35 lines (31 loc) · 882 Bytes
/
Copy pathCouldNotProcessData.php
File metadata and controls
35 lines (31 loc) · 882 Bytes
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
<?php
declare(strict_types=1);
namespace PetrKnap\Binary\Exception;
use RuntimeException;
use Throwable;
/**
* @note this is public helper, this class is not supposed to implement {@see Exception}
*
* @template TData of mixed
*/
abstract class CouldNotProcessData extends RuntimeException
{
/**
* @param non-empty-string $method
* @param TData $data may contain binary data
*/
public function __construct(
string $method,
public readonly mixed $data,
public readonly Throwable|null $reason = null,
) {
parent::__construct(
message: sprintf(
'%s could not process %s',
$method,
is_string($data) ? sprintf('string(%d)', strlen($data)) : (is_object($data) ? get_class($data) : gettype($data)),
),
previous: $reason
);
}
}