|
|
@@ -60,10 +60,15 @@ class StreamHandler extends AbstractProcessingHandler
|
|
|
if (!$this->url) {
|
|
|
throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
|
|
|
}
|
|
|
- $this->stream = @fopen($this->url, 'a');
|
|
|
+ $errorMessage = null;
|
|
|
+ set_error_handler(function ($code, $msg) use (&$errorMessage) {
|
|
|
+ $errorMessage = preg_replace('{^fopen\(.*?\): }', '', $msg);
|
|
|
+ });
|
|
|
+ $this->stream = fopen($this->url, 'a');
|
|
|
+ restore_error_handler();
|
|
|
if (!is_resource($this->stream)) {
|
|
|
$this->stream = null;
|
|
|
- throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened; it may be invalid or not writable.', $this->url));
|
|
|
+ throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$errorMessage, $this->url));
|
|
|
}
|
|
|
}
|
|
|
fwrite($this->stream, (string) $record['formatted']);
|