aboutsummaryrefslogtreecommitdiffstats
path: root/Praspel.php
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-08-29 17:08:47 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-08-29 17:08:47 +0200
commit6e08fe0c98873a6aadb21fa3629294250c4b9c04 (patch)
tree37206681c7bc4afc8cb779a12db7967a8dba443d /Praspel.php
parent3097e3c748dc3bc4784ce58c33304b468ab95d53 (diff)
downloadPraspel-6e08fe0c98873a6aadb21fa3629294250c4b9c04.zip
Praspel-6e08fe0c98873a6aadb21fa3629294250c4b9c04.tar.gz
Praspel-6e08fe0c98873a6aadb21fa3629294250c4b9c04.tar.bz2
Finalize the @throwable verification algorithm.
Diffstat (limited to 'Praspel.php')
-rw-r--r--Praspel.php51
1 files changed, 28 insertions, 23 deletions
diff --git a/Praspel.php b/Praspel.php
index fe76451..5c4b4d1 100644
--- a/Praspel.php
+++ b/Praspel.php
@@ -292,18 +292,33 @@ class Praspel {
}
catch ( \Exception $exception ) {
- // Check exceptional postcondition.
- if(true === $behavior->clauseExists('throwable')) {
-
- $throwable = $behavior->getClause('throwable');
- $arguments['\result'] = $exception;
- $verdict &= $this->checkExceptionalClause(
- $throwable,
- $arguments,
- $exceptions,
- __NAMESPACE__ . '\Exception\Failure\Exceptional'
+ $_verdict = false;
+ $arguments['\result'] = $exception;
+
+ do {
+
+ // Check exceptional postcondition.
+ if(true === $behavior->clauseExists('throwable')) {
+
+ $throwable = $behavior->getClause('throwable');
+ $_verdict |= $this->checkExceptionalClause(
+ $throwable,
+ $arguments
+ );
+ }
+
+ } while( false === $_verdict
+ && null !== $behavior = $behavior->getParent());
+
+ if(false === $_verdict) {
+
+ $exceptions[] = new Exception\Failure\Exceptional(
+ 'The exception %s has been unexpectedly thrown.',
+ 42, array(get_class($arguments['\result']))
);
}
+
+ $verdict &= $_verdict;
}
if(0 < count($exceptions))
@@ -455,18 +470,13 @@ class Praspel {
* Check an exceptional clause.
*
* @access protected
- * @param \Hoa\Praspel\Model\Throwable $clause Clause.
- * @param array &$data Data.
- * @param \Hoa\Praspel\Exception\Group $exceptions Exceptions group.
- * @param string $exception Exception to
- * throw.
+ * @param \Hoa\Praspel\Model\Throwable $clause Clause.
+ * @param array &$data Data.
* @return bool
* @throw \Hoa\Praspel\Exception
*/
protected function checkExceptionalClause ( Model\Throwable $clause,
- Array &$data,
- Exception\Group $exceptions,
- $exception ) {
+ Array &$data ) {
$verdict = false;
@@ -494,11 +504,6 @@ class Praspel {
}
}
- if(false === $verdict)
- $exceptions[] = new $exception(
- 'The exception %s has been unexpectedly thrown.',
- 7, array(get_class($data['\result'])));
-
return $verdict;
}