File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Tempest \Core ;
4+
5+ use Tempest \DateTime \Exception \RuntimeException ;
6+
7+ final class CouldNotRegisterInternalStorage extends RuntimeException
8+ {
9+ public static function fileExists (string $ path ): self
10+ {
11+ return new self ("Unable to create internal storage directory, as a file with the same name already exists at ` {$ path }` " );
12+ }
13+
14+ public static function directoryNotWritable (string $ path ): self
15+ {
16+ return new self ("Unable to create internal storage directory because of insufficient user permission on the root directory at ` {$ path }` " );
17+ }
18+
19+ public static function noPermission (string $ path ): self
20+ {
21+ return new self ("Insufficient user permission to write to internal storage directory as ` {$ path }`. " );
22+ }
23+ }
Original file line number Diff line number Diff line change @@ -169,14 +169,14 @@ public function registerInternalStorage(): self
169169
170170 if (! is_dir ($ path )) {
171171 if (file_exists ($ path )) {
172- throw new \ RuntimeException ( ' Unable to create internal storage directory, as a file with the same name (.tempest) already exists. ' );
172+ throw CouldNotRegisterInternalStorage:: fileExists ( $ path );
173173 }
174174
175175 if (! mkdir ($ path , recursive: true )) {
176- throw new \ RuntimeException ( ' Unable to create internal storage directory because of insufficient user permission on the root directory. ' );
176+ throw CouldNotRegisterInternalStorage:: directoryNotWritable ( $ path );
177177 }
178178 } elseif (! is_writable ($ path )) {
179- throw new \ RuntimeException ( ' Insufficient user permission to write to internal storage directory. ' );
179+ throw CouldNotRegisterInternalStorage:: noPermission ( $ path );
180180 }
181181
182182 $ this ->internalStorage = realpath ($ path );
You can’t perform that action at this time.
0 commit comments