Skip to content

Commit fd08a32

Browse files
committed
forward caught exception
1 parent 9ec5e22 commit fd08a32

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

PropertyAccessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function setValue(&$objectOrArray, $propertyPath, $value)
229229
$value = $zval[self::VALUE];
230230
}
231231
} catch (\TypeError $e) {
232-
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0);
232+
self::throwInvalidArgumentException($e->getMessage(), $e->getTrace(), 0, $e);
233233

234234
// It wasn't thrown in this class so rethrow it
235235
throw $e;
@@ -253,7 +253,7 @@ public static function handleError($type, $message, $file, $line, $context = [])
253253
return null !== self::$previousErrorHandler && false !== \call_user_func(self::$previousErrorHandler, $type, $message, $file, $line, $context);
254254
}
255255

256-
private static function throwInvalidArgumentException($message, $trace, $i)
256+
private static function throwInvalidArgumentException($message, $trace, $i, $previous = null)
257257
{
258258
// the type mismatch is not caused by invalid arguments (but e.g. by an incompatible return type hint of the writer method)
259259
if (0 !== strpos($message, 'Argument ')) {
@@ -267,7 +267,7 @@ private static function throwInvalidArgumentException($message, $trace, $i)
267267
$type = substr($message, 2 + $j, strpos($message, ' given', $j) - $j - 2);
268268
$message = substr($message, $pos, $j - $pos);
269269

270-
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given', $message, 'NULL' === $type ? 'null' : $type));
270+
throw new InvalidArgumentException(sprintf('Expected argument of type "%s", "%s" given', $message, 'NULL' === $type ? 'null' : $type), 0, $previous);
271271
}
272272
}
273273

0 commit comments

Comments
 (0)