From 47f6dea624516fb2f6a2b1907ee4be0f9671b40d Mon Sep 17 00:00:00 2001 From: Simon Holywell Date: Wed, 14 Nov 2012 16:13:28 +0000 Subject: [PATCH] Correct replace_outside_quotes error handling --- idiorm.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/idiorm.php b/idiorm.php index d2b4b170..9d93f595 100644 --- a/idiorm.php +++ b/idiorm.php @@ -1459,8 +1459,9 @@ protected function _str_replace_outside_quotes(){ )* # Zero or more string chunks. \z # Anchor to end of string. /sx'; - if (!preg_match($re_valid, $this->subject)) // Exit if string is invalid. - exit("Error! String not valid."); + if (!preg_match($re_valid, $this->subject)) { + throw new IdiormStringException("Subject string is not valid in the replace_outside_quotes context."); + } $re_parse = '/ # Match one chunk of a valid string having embedded quoted substrings. ( # Either $1: Quoted chunk. @@ -1487,4 +1488,9 @@ protected function _str_replace_outside_quotes_cb($matches) { return preg_replace('/'. preg_quote($this->search, '/') .'/', $this->replace, $matches[2]); } - } \ No newline at end of file + } + + /** + * A placeholder for exceptions eminating from the IdiormString class + */ + class IdiormStringException {} \ No newline at end of file