-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from pirate-ship-software/master
Use NotFoundException instead \Exception, if a value could not be retrieved
- Loading branch information
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Gressus\Tools\Exception; | ||
|
||
use Exception; | ||
|
||
class NotFoundException extends Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,9 @@ | |
* @package Gressus_Tools | ||
***************************************************************/ | ||
namespace Gressus\Tools; | ||
|
||
use Gressus\Tools\Exception\NotFoundException; | ||
|
||
/** | ||
* Object Access | ||
* | ||
|
@@ -19,8 +22,6 @@ | |
* @author Felix Krüger <[email protected]> | ||
* | ||
*/ | ||
|
||
|
||
class ObjectAccess { | ||
|
||
/** | ||
|
@@ -77,7 +78,7 @@ public static function get($object, $query, $default = null){ | |
public static function getOrThrowException($object, $query){ | ||
$value = self::get($object,$query); | ||
if($value === null){ | ||
throw new \Exception('Could Not Retrieve '.$query); | ||
throw new NotFoundException('Could Not Retrieve '.$query); | ||
} | ||
return $value; | ||
} | ||
|