1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 12:47:39 +02:00

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.
This commit is contained in:
Max Ageev
2022-06-09 14:23:32 +03:00
committed by Jordi Boggiano
parent f958fdac0f
commit af8efac0d5

View File

@@ -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));
}
}