We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 839e68e commit dd775b4Copy full SHA for dd775b4
.gitignore
@@ -1,5 +1,6 @@
1
composer.phar
2
composer.lock
3
phpunit.xml
4
+.phpunit.result*
5
build/
6
vendor/
src/StreamFactory.php
@@ -19,7 +19,20 @@ public function createStream(string $content = ''): StreamInterface
19
20
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
21
{
22
- $resource = fopen($file, $mode);
+ try {
23
+ $resource = fopen($file, $mode);
24
+ } catch (\Throwable $e) {
25
+ throw new \RuntimeException(
26
+ sprintf(
27
+ 'Unable to open "%s" using mode "%s": "%s',
28
+ $file,
29
+ $mode,
30
+ $e->getMessage(),
31
+ ),
32
+ 0,
33
+ $e,
34
+ );
35
+ }
36
37
return $this->createStreamFromResource($resource);
38
}
0 commit comments