Browse Source

Check if errorMessage contain error "File exists"

Fixes #1678, closes #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.
Max Ageev 3 years ago
parent
commit
af8efac0d5
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/Monolog/Handler/StreamHandler.php

+ 1 - 1
src/Monolog/Handler/StreamHandler.php

@@ -212,7 +212,7 @@ class StreamHandler extends AbstractProcessingHandler
             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));
             }
         }