mirror of
https://github.com/Intervention/image.git
synced 2025-08-01 11:30:16 +02:00
Add more detailed exception messages for NotWritableException
This commit is contained in:
15
src/File.php
15
src/File.php
@@ -28,6 +28,21 @@ class File implements FileInterface
|
||||
*/
|
||||
public function save(string $filepath): void
|
||||
{
|
||||
$dir = pathinfo($filepath, PATHINFO_DIRNAME);
|
||||
|
||||
if (!is_dir($dir)) {
|
||||
throw new NotWritableException(
|
||||
"Can't write image to path. Directory does not exist."
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_writable($dir)) {
|
||||
throw new NotWritableException(
|
||||
"Can't write image to path. Directory is not writable."
|
||||
);
|
||||
}
|
||||
|
||||
// write date
|
||||
$saved = @file_put_contents($filepath, (string) $this);
|
||||
if ($saved === false) {
|
||||
throw new NotWritableException(
|
||||
|
Reference in New Issue
Block a user