mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-26 20:04:51 +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()) {
|
||||
$message .= \sprintf("; %s", $error["message"]);
|
||||
}
|
||||
throw new StreamException($message);
|
||||
throw new CannotWriteChunkException($data, $message);
|
||||
}
|
||||
|
||||
$writes->unshift([$data, $previous, $deferred]);
|
||||
|
Loading…
Reference in New Issue
Block a user