Throw a specific exception if MD_STD::mkdir fails

Close #8
This commit is contained in:
Joshua Ramon Enslin 2023-11-27 01:30:43 +01:00
parent db31822a3f
commit 8006695093
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,18 @@
<?PHP
declare(strict_types = 1);
/**
* Reports a failure to create a new directory.
*/
final class MDFailedToCreateDirectory extends Exception {
/**
* Error message.
*
* @return string
*/
public function errorMessage() {
//error message
return 'Failed to encode JSON data.';
}
}

View File

@ -71,7 +71,7 @@ final class MD_STD {
return;
}
if (\mkdir($pathname, $mode, $recursive) === false) {
throw new Exception("Failed to create directory: $pathname");
throw new MDFailedToCreateDirectory("Failed to create directory: $pathname");
}
}