Skip to content

Commit

Permalink
Add own exception namespace
Browse files Browse the repository at this point in the history
Exceptions from this library all extend the IIIFException - so a simple
instance of query is simpler.
  • Loading branch information
ipf committed May 11, 2017
1 parent 0259174 commit 94d897c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Exception/DataException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Subugoe\IIIFBundle\Exception;

class DataException extends IIIFException
{
}
7 changes: 7 additions & 0 deletions Exception/IIIFException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Subugoe\IIIFBundle\Exception;

class IIIFException extends \Exception
{
}
2 changes: 1 addition & 1 deletion Exception/MalformedDocumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

namespace Subugoe\IIIFBundle\Exception;

class MalformedDocumentException extends \Exception
class MalformedDocumentException extends IIIFException
{
}
7 changes: 6 additions & 1 deletion Service/PresentationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Subugoe\IIIFBundle\Service;

use Subugoe\IIIFBundle\Exception\DataException;
use Subugoe\IIIFBundle\Exception\MalformedDocumentException;
use Subugoe\IIIFBundle\Model\LogicalStructure;
use Subugoe\IIIFBundle\Model\PhysicalStructure;
Expand Down Expand Up @@ -501,7 +502,11 @@ private function getPreviousHierarchyStructure(\Subugoe\IIIFBundle\Model\Documen
}
}

throw new \Exception('Parent structure not defined');
throw new DataException(vsprintf(
'Parent structure at position %d with level %d and parent level %d not defined', [
$position, $level, $parentLevel,
]
), 1494506264);
}

/**
Expand Down

0 comments on commit 94d897c

Please sign in to comment.