Skip to content

Commit f38d729

Browse files
authored
Merge pull request #5 from manitra/patch-1
Allow users to get the runtime exception from 500 error pipes.
2 parents 8e651cf + 46c86b4 commit f38d729

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/WaterPipe/WaterPipe.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ class WaterPipe
154154
*/
155155
private $_mapRegistry;
156156

157+
/**
158+
* In case an exception occurs during pipe execution, it will be
159+
* stored here for user code to read in middlewares and error handlers
160+
*
161+
* @var \Exception
162+
*/
163+
private $_runningException;
164+
157165
/**
158166
* @return WaterPipe
159167
*/
@@ -206,6 +214,7 @@ public function __construct()
206214
$this->_errorsRegistry = array();
207215
$this->_pipesRegistry = array();
208216
$this->_mapRegistry = array();
217+
$this->_runningException = null;
209218
}
210219

211220
/**
@@ -430,6 +439,16 @@ public function run()
430439
$pipe[1]->_runBase($pipe[0]);
431440
}
432441
}
442+
443+
/**
444+
* If an exception has occured while running the pipe
445+
* This method will return that exception.
446+
* Otherwise, will return null.
447+
* @return \Exception
448+
*/
449+
function getRunningException () {
450+
return $this->_runningException;
451+
}
433452

434453
/**
435454
* @param string $baseUri
@@ -546,6 +565,8 @@ private function _executeRequest()
546565
// NOTE: No code will be executed after this call...
547566
$this->_executeAction($runner);
548567
} catch (\Exception $e) {
568+
$this->_runningException = $e;
569+
549570
if (isset($this->_errorsRegistry[500])) {
550571
$this->_executeAction($this->_errorsRegistry[500]);
551572
} else {

0 commit comments

Comments
 (0)