-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathException.php
More file actions
93 lines (87 loc) · 2.06 KB
/
Copy pathException.php
File metadata and controls
93 lines (87 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* This file is part of the Stack package.
*
* (c) Andrzej Kostrzewa <andkos11@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Stack\Routing;
/**
* Generic package exception.
*
* @author Andrzej Kostrzewa <andkos11@gmail.com>
*/
class Exception extends \Exception
{
/**
* The rule was not allowed.
*
* @param string $path
* @param string $class
* @param string $route
*
* @return Exception\RuleNotAllowed
* @throws Exception\RuleNotAllowed
*/
public static function RuleNotAllowed(string $path, string $class, string $route)
{
throw new Exception\RuleNotAllowed(
sprintf(
'%s FAILED %s ON %s',
$path,
$class,
$route
)
);
}
/**
* The rule was not found.
*
* @param string $rule
* @param string $key
*
* @return Exception\RuleNotFound
* @throws Exception\RuleNotFound
*/
public static function RuleNotFound(string $rule, string $key)
{
throw new Exception\RuleNotFound(
sprintf(
'Expected Rule, got %s for key %s',
$rule,
$key
)
);
}
/**
* The resource was not found.
*
* @param string $path
*
* @return Exception\ResourceNotFound
* @throws Exception\ResourceNotFound
*/
public static function ResourceNotFound(string $path)
{
throw new Exception\ResourceNotFound(
sprintf('No routes found for "%s".', $path)
);
}
/**
* A route name was not found.
*
* @param string $name
*
* @return Exception\RouteNotFound
* @throws Exception\RouteNotFound
*/
public static function RouteNotFound(string $name)
{
throw new Exception\RouteNotFound(
sprintf('No route found for "%s".', $name)
);
}
}