| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry; |
| 5 |
|
| 6 |
/** |
| 7 |
* The exception mechanism is an optional field residing in the Exception Interface. |
| 8 |
* It carries additional information about the way the exception was created on the |
| 9 |
* target system. This includes general exception values obtained from operating |
| 10 |
* system or runtime APIs, as well as mechanism-specific values. |
| 11 |
*/ |
| 12 |
final class ExceptionMechanism |
| 13 |
{ |
| 14 |
public const TYPE_GENERIC = 'generic'; |
| 15 |
/** |
| 16 |
* @var string Unique identifier of this mechanism determining rendering and |
| 17 |
* processing of the mechanism data |
| 18 |
*/ |
| 19 |
private $type; |
| 20 |
/** |
| 21 |
* @var bool Flag indicating whether the exception has been handled by the |
| 22 |
* user (e.g. via try..catch) |
| 23 |
*/ |
| 24 |
private $handled; |
| 25 |
/** |
| 26 |
* @var array<string, mixed> Arbitrary extra data that might help the user |
| 27 |
* understand the error thrown by this mechanism |
| 28 |
*/ |
| 29 |
private $data; |
| 30 |
/** |
| 31 |
* Class constructor. |
| 32 |
* |
| 33 |
* @param string $type Unique identifier of this mechanism determining |
| 34 |
* rendering and processing of the mechanism data |
| 35 |
* @param bool $handled Flag indicating whether the exception has been |
| 36 |
* handled by the user (e.g. via try..catch) |
| 37 |
* @param array<string, mixed> $data Arbitrary extra data that might help the user |
| 38 |
* understand the error thrown by this mechanism |
| 39 |
*/ |
| 40 |
public function __construct(string $type, bool $handled, array $data = []) |
| 41 |
{ |
| 42 |
$this->type = $type; |
| 43 |
$this->handled = $handled; |
| 44 |
$this->data = $data; |
| 45 |
} |
| 46 |
/** |
| 47 |
* Returns the unique identifier of this mechanism determining rendering and |
| 48 |
* processing of the mechanism data. |
| 49 |
*/ |
| 50 |
public function getType() : string |
| 51 |
{ |
| 52 |
return $this->type; |
| 53 |
} |
| 54 |
/** |
| 55 |
* Returns the flag indicating whether the exception has been handled by the |
| 56 |
* user (e.g. via try..catch). |
| 57 |
*/ |
| 58 |
public function isHandled() : bool |
| 59 |
{ |
| 60 |
return $this->handled; |
| 61 |
} |
| 62 |
/** |
| 63 |
* Returns arbitrary extra data that might help the user understand the error |
| 64 |
* thrown by this mechanism. |
| 65 |
* |
| 66 |
* @return array<string, mixed> |
| 67 |
*/ |
| 68 |
public function getData() : array |
| 69 |
{ |
| 70 |
return $this->data; |
| 71 |
} |
| 72 |
/** |
| 73 |
* Sets the arbitrary extra data. |
| 74 |
* |
| 75 |
* @param array<string, mixed> $data |
| 76 |
*/ |
| 77 |
public function setData(array $data) : self |
| 78 |
{ |
| 79 |
$this->data = $data; |
| 80 |
return $this; |
| 81 |
} |
| 82 |
} |
| 83 |
|