diff --git a/src/Drivers/Abstract/Decoders/AbstractDecoder.php b/src/Drivers/Abstract/Decoders/AbstractDecoder.php index a40e0264..a1ee53ea 100644 --- a/src/Drivers/Abstract/Decoders/AbstractDecoder.php +++ b/src/Drivers/Abstract/Decoders/AbstractDecoder.php @@ -22,7 +22,7 @@ abstract class AbstractDecoder implements DecoderInterface $decoded = $this->decode($input); } catch (DecoderException $e) { if (!$this->hasSuccessor()) { - $this->fail(); + $this->fail($e->getMessage()); } return $this->successor->handle($input); @@ -36,9 +36,9 @@ abstract class AbstractDecoder implements DecoderInterface return $this->successor !== null; } - protected function fail(): void + protected function fail(string $message = 'Unable to decode given input.'): void { - throw new DecoderException("Unable to decode given input."); + throw new DecoderException($message); } protected function inputType($input): AbstractType diff --git a/tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php b/tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php index 7d567344..b6d7f261 100644 --- a/tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php +++ b/tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php @@ -30,7 +30,6 @@ class AbstractDecoderTest extends TestCase $decoder->shouldReceive('decode')->with('test input')->andThrow(DecoderException::class); $this->expectException(DecoderException::class); - $this->expectExceptionMessage('Unable to decode given input.'); $decoder->handle('test input'); }