File tree Expand file tree Collapse file tree 5 files changed +154
-0
lines changed
Expand file tree Collapse file tree 5 files changed +154
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /**
6+ * PHP simple library for managing JSON files.
7+ *
8+ * @author Josantonius <hello@josantonius.dev>
9+ * @copyright 2016 (c) Josantonius
10+ * @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11+ * @link https://github.com/josantonius/php-json
12+ * @since 2.0.0
13+ */
14+ namespace Josantonius \Json \Exception ;
15+
16+ /**
17+ * You can use an exception and error handler with this library.
18+ *
19+ * @link https://github.com/josantonius/php-errorhandler
20+ */
21+ class CreateDirectoryException extends \Exception
22+ {
23+ public function __construct (string $ path , \Throwable $ th = null )
24+ {
25+ $ lastError = error_get_last ()['message ' ] ?? '' ;
26+
27+ $ message = "Could not create directory in ' $ path'. " ;
28+ $ message .= $ lastError ? " $ lastError. " : '' ;
29+
30+ parent ::__construct ($ th ? $ th ->getMessage () : $ message , 0 , $ th );
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /**
6+ * PHP simple library for managing JSON files.
7+ *
8+ * @author Josantonius <hello@josantonius.dev>
9+ * @copyright 2016 (c) Josantonius
10+ * @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11+ * @link https://github.com/josantonius/php-json
12+ * @since 2.0.0
13+ */
14+ namespace Josantonius \Json \Exception ;
15+
16+ /**
17+ * You can use an exception and error handler with this library.
18+ *
19+ * @link https://github.com/josantonius/php-errorhandler
20+ */
21+ class CreateFileException extends \Exception
22+ {
23+ public function __construct (string $ filepath , \Throwable $ th = null )
24+ {
25+ $ lastError = error_get_last ()['message ' ] ?? '' ;
26+
27+ $ message = "Could not create file ' $ filepath'. " ;
28+ $ message .= $ lastError ? " $ lastError. " : '' ;
29+
30+ parent ::__construct ($ th ? $ th ->getMessage () : $ message , 0 , $ th );
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /**
6+ * PHP simple library for managing JSON files.
7+ *
8+ * @author Josantonius <hello@josantonius.dev>
9+ * @copyright 2016 (c) Josantonius
10+ * @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11+ * @link https://github.com/josantonius/php-json
12+ * @since 2.0.0
13+ */
14+ namespace Josantonius \Json \Exception ;
15+
16+ /**
17+ * You can use an exception and error handler with this library.
18+ *
19+ * @link https://github.com/josantonius/php-errorhandler
20+ */
21+ class GetFileException extends \Exception
22+ {
23+ public function __construct (string $ filepath , \Throwable $ th = null )
24+ {
25+ $ lastError = error_get_last ()['message ' ] ?? '' ;
26+
27+ $ message = "Error reading file: ' $ filepath'. " ;
28+ $ message .= $ lastError ? " $ lastError. " : '' ;
29+
30+ parent ::__construct ($ th ? $ th ->getMessage () : $ message , 0 , $ th );
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /**
6+ * PHP simple library for managing JSON files.
7+ *
8+ * @author Josantonius <hello@josantonius.dev>
9+ * @copyright 2016 (c) Josantonius
10+ * @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11+ * @link https://github.com/josantonius/php-json
12+ * @since 2.0.0
13+ */
14+ namespace Josantonius \Json \Exception ;
15+
16+ /**
17+ * You can use an exception and error handler with this library.
18+ *
19+ * @link https://github.com/josantonius/php-errorhandler
20+ */
21+ class JsonErrorException extends \Exception
22+ {
23+ public function __construct (\Throwable $ th = null )
24+ {
25+ $ message = 'JSON error: ' . json_last_error_msg ();
26+
27+ parent ::__construct ($ th ? $ th ->getMessage () : $ message , 0 , $ th );
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /**
6+ * PHP simple library for managing JSON files.
7+ *
8+ * @author Josantonius <hello@josantonius.dev>
9+ * @copyright 2016 (c) Josantonius
10+ * @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11+ * @link https://github.com/josantonius/php-json
12+ * @since 2.0.0
13+ */
14+ namespace Josantonius \Json \Exception ;
15+
16+ /**
17+ * You can use an exception and error handler with this library.
18+ *
19+ * @link https://github.com/josantonius/php-errorhandler
20+ */
21+ class UnavailableMethodException extends \Exception
22+ {
23+ public function __construct (string $ method , \Throwable $ th = null )
24+ {
25+ $ message = 'The " ' . $ method . '" method is not available for remote JSON files. ' ;
26+
27+ parent ::__construct ($ th ? $ th ->getMessage () : $ message , 0 , $ th );
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments