| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry; |
| 5 |
|
| 6 |
/** |
| 7 |
* This class represents the Exception Interface and contains the details of an |
| 8 |
* exception or error that occurred in the program. |
| 9 |
* |
| 10 |
* @author Stefano Arlandini <[email protected]> |
| 11 |
*/ |
| 12 |
final class ExceptionDataBag |
| 13 |
{ |
| 14 |
/** |
| 15 |
* @var string The type of exception, e.g. RuntimeException |
| 16 |
*/ |
| 17 |
private $type; |
| 18 |
/** |
| 19 |
* @var string The value of the exception |
| 20 |
*/ |
| 21 |
private $value; |
| 22 |
/** |
| 23 |
* @var Stacktrace|null An optional stack trace object corresponding to the Stack Trace Interface |
| 24 |
*/ |
| 25 |
private $stacktrace; |
| 26 |
/** |
| 27 |
* @var ExceptionMechanism|null An optional object describing the mechanism that created this exception |
| 28 |
*/ |
| 29 |
private $mechanism; |
| 30 |
public function __construct(\Throwable $exception, ?Stacktrace $stacktrace = null, ?ExceptionMechanism $mechanism = null) |
| 31 |
{ |
| 32 |
$this->type = \get_class($exception); |
| 33 |
$this->value = $exception->getMessage(); |
| 34 |
$this->stacktrace = $stacktrace; |
| 35 |
$this->mechanism = $mechanism; |
| 36 |
} |
| 37 |
/** |
| 38 |
* Gets the type of exception, e.g. RuntimeException. |
| 39 |
*/ |
| 40 |
public function getType() : string |
| 41 |
{ |
| 42 |
return $this->type; |
| 43 |
} |
| 44 |
/** |
| 45 |
* Sets the type of the exception. |
| 46 |
* |
| 47 |
* @param string $type The exception type |
| 48 |
*/ |
| 49 |
public function setType(string $type) : self |
| 50 |
{ |
| 51 |
$this->type = $type; |
| 52 |
return $this; |
| 53 |
} |
| 54 |
/** |
| 55 |
* Gets the value of the exception. |
| 56 |
*/ |
| 57 |
public function getValue() : string |
| 58 |
{ |
| 59 |
return $this->value; |
| 60 |
} |
| 61 |
/** |
| 62 |
* Sets the value of the exception. |
| 63 |
*/ |
| 64 |
public function setValue(string $value) : self |
| 65 |
{ |
| 66 |
$this->value = $value; |
| 67 |
return $this; |
| 68 |
} |
| 69 |
/** |
| 70 |
* Gets the stack trace object corresponding to the Stack Trace Interface. |
| 71 |
*/ |
| 72 |
public function getStacktrace() : ?Stacktrace |
| 73 |
{ |
| 74 |
return $this->stacktrace; |
| 75 |
} |
| 76 |
/** |
| 77 |
* Sets the stack trace object corresponding to the Stack Trace Interface. |
| 78 |
* |
| 79 |
* @param Stacktrace $stacktrace The stacktrace |
| 80 |
*/ |
| 81 |
public function setStacktrace(Stacktrace $stacktrace) : self |
| 82 |
{ |
| 83 |
$this->stacktrace = $stacktrace; |
| 84 |
return $this; |
| 85 |
} |
| 86 |
/** |
| 87 |
* Gets the object describing the mechanism that created this exception. |
| 88 |
*/ |
| 89 |
public function getMechanism() : ?ExceptionMechanism |
| 90 |
{ |
| 91 |
return $this->mechanism; |
| 92 |
} |
| 93 |
/** |
| 94 |
* Sets the object describing the mechanism that created this exception. |
| 95 |
* |
| 96 |
* @param ExceptionMechanism|null $mechanism The mechanism that created this exception |
| 97 |
*/ |
| 98 |
public function setMechanism(?ExceptionMechanism $mechanism) : self |
| 99 |
{ |
| 100 |
$this->mechanism = $mechanism; |
| 101 |
return $this; |
| 102 |
} |
| 103 |
} |
| 104 |
|