21 declare(strict_types=1);
59 private $errorMessage;
63 public function __construct(
string $stage,
string $errorMessage,
string $query = null, array $args = null){
64 $this->stage = $stage;
65 $this->errorMessage = $errorMessage;
66 $this->query = $query;
69 parent::__construct(
"SQL $stage error: $errorMessage" . ($query === null ?
"" : (
", for query $query | " .
json_encode($args))));
88 return $this->errorMessage;
115 $traceProperty = (
new ReflectionClass(Exception::class))->getProperty(
'trace');
116 $traceProperty->setAccessible(
true);
117 $flatten =
function(&$value){
121 '(Closure at %s:%s)',
122 $closureReflection->getFileName(),
123 $closureReflection->getStartLine()
132 $trace = $traceProperty->getValue($this);
133 foreach($trace as &$call){
134 array_walk_recursive($call[
'args'], $flatten);
137 $traceProperty->setValue($this, $trace);
138 }
while($exception = $this->getPrevious());
139 $traceProperty->setAccessible(
false);
__construct(string $stage, string $errorMessage, string $query=null, array $args=null)