mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-30 04:19:23 +01:00
Throw new exception carrying $chunk when fwrite returns 0
This commit is contained in:
parent
6bbfcb6f47
commit
eb4d03504d
23
lib/CannotWriteChunkException.php
Normal file
23
lib/CannotWriteChunkException.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Amp\ByteStream;
|
||||||
|
|
||||||
|
final class CannotWriteChunkException extends StreamException
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $chunk;
|
||||||
|
|
||||||
|
public function __construct(string $chunk, string $message = "", int $code = 0, \Throwable $previous = null)
|
||||||
|
{
|
||||||
|
parent::__construct($message, $code, $previous);
|
||||||
|
|
||||||
|
$this->chunk = $chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getChunk(): string
|
||||||
|
{
|
||||||
|
return $this->chunk;
|
||||||
|
}
|
||||||
|
}
|
@ -92,7 +92,7 @@ final class ResourceOutputStream implements OutputStream
|
|||||||
if ($error = \error_get_last()) {
|
if ($error = \error_get_last()) {
|
||||||
$message .= \sprintf("; %s", $error["message"]);
|
$message .= \sprintf("; %s", $error["message"]);
|
||||||
}
|
}
|
||||||
throw new StreamException($message);
|
throw new CannotWriteChunkException($data, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
$writes->unshift([$data, $previous, $deferred]);
|
$writes->unshift([$data, $previous, $deferred]);
|
||||||
|
Loading…
Reference in New Issue
Block a user