Skip to content

Commit

Permalink
Check if errorMessage contain error "File exists"
Browse files Browse the repository at this point in the history
Fixes Seldaek#1678, closes Seldaek#1685

When we try to create directory we got error and find out that error is to the fact that directory already was created for us.
If that the case we should not throw exception as it's fine now...
If file was deleted after that it's not problem of this funtion.
  • Loading branch information
Legion112 authored and Seldaek committed Jul 22, 2022
1 parent f958fda commit af8efac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Monolog/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private function createDir(string $url): void
set_error_handler([$this, 'customErrorHandler']);
$status = mkdir($dir, 0777, true);
restore_error_handler();
if (false === $status && !is_dir($dir)) {
if (false === $status && !is_dir($dir) && strpos($this->errorMessage, 'File exists') !== false) {
throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: '.$this->errorMessage, $dir));
}
}
Expand Down

0 comments on commit af8efac

Please sign in to comment.