Skip to content

Commit

Permalink
adds a check for a valid uri and throws an exception with
Browse files Browse the repository at this point in the history
error code 7 if its not
  • Loading branch information
shinobu committed Nov 13, 2016
1 parent ca59bc7 commit 4bef84a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/Erfurt/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
class Erfurt_Exception extends Exception {

//Used for exceptions that found invalid URI/IRI's
const INVALID_IRI_ERROR = 7;

function display($pre = true) {
if ($pre) print '<pre>';
echo "Erfurt_Exception: code $this->code ($this->message) " .
Expand Down
7 changes: 7 additions & 0 deletions library/Erfurt/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,13 @@ public function getModel($modelIri, $useAc = true)
*/
public function getNewModel($modelIri, $baseIri = '', $type = Erfurt_Store::MODEL_TYPE_OWL, $useAc = true)
{
//check if the $modelIri is a valid IRI
if (!Erfurt_Uri::check($modelIri)) {
$message = defined('_EFDEBUG')
? 'Failed creating the model. The chosen IRI is not valid.'
: 'Failed creating the model.';
throw new Erfurt_Store_Exception($message, Erfurt_Exception::INVALID_IRI_ERROR);
}
// check model availablity
if ($this->isModelAvailable($modelIri, false)) {
// if debug mode is enabled create a more detailed exception description. If debug mode is disabled the
Expand Down

0 comments on commit 4bef84a

Please sign in to comment.