Skip to content

Commit 0c1b6c6

Browse files
Stephan Wentzpl-github
authored andcommitted
expose input in exception instead of adding it to the exception message
1 parent a1b7803 commit 0c1b6c6

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/Exception/UnserializeFailedException.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,32 @@
1313

1414
namespace Brainbits\Blocking\Exception;
1515

16+
use Throwable;
17+
1618
/**
1719
* Unserialize failed exception.
1820
*/
1921
final class UnserializeFailedException extends RuntimeException
2022
{
23+
private $input;
24+
25+
public function __construct(string $message, ?int $code, ?Throwable $previous, string $input)
26+
{
27+
parent::__construct($message, $code, $previous);
28+
29+
$this->input = $input;
30+
}
31+
2132
/**
2233
* @param mixed $input
2334
*/
2435
public static function createFromInput($input): self
2536
{
26-
return new self("Unserialize failed: ".$input);
37+
return new self("Unserialize failed.", null, null, (string) $input);
38+
}
39+
40+
public function getInput(): string
41+
{
42+
return $this->input;
2743
}
2844
}

0 commit comments

Comments
 (0)