Skip to content

Commit

Permalink
Merge pull request #2 from pirate-ship-software/master
Browse files Browse the repository at this point in the history
Use NotFoundException instead \Exception, if a value could not be retrieved
  • Loading branch information
bazen authored Mar 8, 2023
2 parents f4d01b1 + af106fe commit e60987f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Classes/Exception/NotFoundException.php
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
{
}
7 changes: 4 additions & 3 deletions Classes/ObjectAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
* @package Gressus_Tools
***************************************************************/
namespace Gressus\Tools;

use Gressus\Tools\Exception\NotFoundException;

/**
* Object Access
*
Expand All @@ -19,8 +22,6 @@
* @author Felix Krüger <[email protected]>
*
*/


class ObjectAccess {

/**
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e60987f

Please sign in to comment.