mirror of
https://github.com/Intervention/image.git
synced 2025-09-02 18:32:56 +02:00
Add exception message to AbstractDecoder::fail()
This commit is contained in:
@@ -22,7 +22,7 @@ abstract class AbstractDecoder implements DecoderInterface
|
|||||||
$decoded = $this->decode($input);
|
$decoded = $this->decode($input);
|
||||||
} catch (DecoderException $e) {
|
} catch (DecoderException $e) {
|
||||||
if (!$this->hasSuccessor()) {
|
if (!$this->hasSuccessor()) {
|
||||||
$this->fail();
|
$this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->successor->handle($input);
|
return $this->successor->handle($input);
|
||||||
@@ -36,9 +36,9 @@ abstract class AbstractDecoder implements DecoderInterface
|
|||||||
return $this->successor !== null;
|
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
|
protected function inputType($input): AbstractType
|
||||||
|
@@ -30,7 +30,6 @@ class AbstractDecoderTest extends TestCase
|
|||||||
$decoder->shouldReceive('decode')->with('test input')->andThrow(DecoderException::class);
|
$decoder->shouldReceive('decode')->with('test input')->andThrow(DecoderException::class);
|
||||||
|
|
||||||
$this->expectException(DecoderException::class);
|
$this->expectException(DecoderException::class);
|
||||||
$this->expectExceptionMessage('Unable to decode given input.');
|
|
||||||
|
|
||||||
$decoder->handle('test input');
|
$decoder->handle('test input');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user