1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-31 01:29:51 +02:00

Add exception message to AbstractDecoder::fail()

This commit is contained in:
Oliver Vogel
2022-05-22 10:59:38 +02:00
parent 3b8629c54e
commit 6dd434c294
2 changed files with 3 additions and 4 deletions

View File

@@ -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

View File

@@ -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');
}