File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 13
13
use PhpPlatform \Annotations \Annotation ;
14
14
use PhpPlatform \Errors \Exceptions \Http \_4XX \Unauthorized ;
15
15
use PhpPlatform \Errors \Exceptions \Persistence \NoAccessException ;
16
+ use PhpPlatform \Errors \Exceptions \Persistence \DataNotFoundException ;
16
17
17
18
class Route {
18
19
@@ -86,7 +87,11 @@ static function run($uri = null){
86
87
$ message = "Internal Server Error " ;
87
88
}
88
89
$ httpResponse = new HTTPResponse ($ h ->getCode (),$ message );
90
+ }catch (DataNotFoundException $ e ){ // DataNotFoundException becomes 'Not Found' response
91
+ new NotFound (); // for logging purpose
92
+ $ httpResponse = new HTTPResponse (404 ,'Not Found ' );
89
93
}catch (NoAccessException $ e ){ // NoAccessException becomes Unauthorized response
94
+ new Unauthorized (); // for logging purpose
90
95
$ httpResponse = new HTTPResponse (401 ,'Unauthorized ' );
91
96
}catch (\Exception $ e ){
92
97
new InternalServerError ($ e ->getMessage ()); // for logging purposes
You can’t perform that action at this time.
0 commit comments