From 5709f3ec57ae1482c0f317ede98d5938bb268fe3 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 21 Aug 2012 11:13:05 -0500 Subject: [PATCH] [zendframework/zf2#2210] Pass ErrorHandler::stop() result as previous exception - Per @mark-mabe - Any place where an exception is throw immediately following an ErrorHandler::stop() call should pass the result of that call as the previous exception. --- src/Filter/Regex.php | 4 ++-- src/Writer/Stream.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Filter/Regex.php b/src/Filter/Regex.php index 5aa8e4dc..b699480d 100644 --- a/src/Filter/Regex.php +++ b/src/Filter/Regex.php @@ -45,12 +45,12 @@ public function __construct($regex) } ErrorHandler::start(E_WARNING); $result = preg_match($regex, ''); - ErrorHandler::stop(); + $error = ErrorHandler::stop(); if ($result === false) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid regular expression "%s"', $regex - )); + ), 0, $error); } $this->regex = $regex; } diff --git a/src/Writer/Stream.php b/src/Writer/Stream.php index b7aa2a2e..c5db6d1a 100644 --- a/src/Writer/Stream.php +++ b/src/Writer/Stream.php @@ -82,13 +82,13 @@ public function __construct($streamOrUrl, $mode = null, $logSeparator = null) } else { ErrorHandler::start(); $this->stream = fopen($streamOrUrl, $mode, false); - ErrorHandler::stop(); + $error = ErrorHandler::stop(); if (!$this->stream) { throw new Exception\RuntimeException(sprintf( '"%s" cannot be opened with mode "%s"', $streamOrUrl, $mode - )); + ), 0, $error); } } @@ -112,9 +112,9 @@ protected function doWrite(array $event) ErrorHandler::start(E_WARNING); $result = fwrite($this->stream, $line); - ErrorHandler::stop(); + $error = ErrorHandler::stop(); if (false === $result) { - throw new Exception\RuntimeException("Unable to write to stream"); + throw new Exception\RuntimeException("Unable to write to stream", 0, $error); } }