From 9fa5cc4ed2c9deb9467ca3aea7147f31613b28c2 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Tue, 5 Sep 2017 14:36:47 +0000 Subject: [PATCH] dblayeroo: allow the DBException function to be extended easily to log in the application git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3936 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayeroo.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dblayeroo.php b/dblayeroo.php index 66f2341..b813239 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -2907,6 +2907,17 @@ class dblayeroo */ public function DBException ($message) /* {{{ */ + { + $message = $this->DBExceptionMsg ($message); + throw new \Exception ($message, 500); + } + /* }}} */ + + /** Return the $message adapted with the debug trace if needed + * @param string $message The message to throw in the exception + */ + public function DBExceptionMsg ($message) + /* {{{ */ { $backtrace = debug_backtrace (); if ($this->debug) @@ -2924,10 +2935,10 @@ class dblayeroo $method = $backtrace["function"]; $message .= " ($filename:$line [$method])"; } - throw new \Exception ($message, 500); + return $message; } - /* }}} */ + /* }}} */ /** Debug function * @param mixed ...$message The message to display in debug */