Skip to content

Commit b511953

Browse files
committed
converted DataNotFoundException to 'Not Found' response
1 parent e96a14a commit b511953

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/RESTFul/Routing/Route.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PhpPlatform\Annotations\Annotation;
1414
use PhpPlatform\Errors\Exceptions\Http\_4XX\Unauthorized;
1515
use PhpPlatform\Errors\Exceptions\Persistence\NoAccessException;
16+
use PhpPlatform\Errors\Exceptions\Persistence\DataNotFoundException;
1617

1718
class Route {
1819

@@ -86,7 +87,11 @@ static function run($uri = null){
8687
$message = "Internal Server Error";
8788
}
8889
$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');
8993
}catch (NoAccessException $e){ // NoAccessException becomes Unauthorized response
94+
new Unauthorized(); // for logging purpose
9095
$httpResponse = new HTTPResponse(401,'Unauthorized');
9196
}catch (\Exception $e){
9297
new InternalServerError($e->getMessage()); // for logging purposes

0 commit comments

Comments
 (0)