4 * @version V4.22 15 Apr 2004 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
\r
5 * Released under both BSD license and Lesser GPL library license.
\r
6 * Whenever there is any discrepancy between the two licenses,
\r
7 * the BSD license will take precedence.
\r
9 * Set tabs to 4 for best viewing.
\r
11 * Latest version is available at http://php.weblogs.com
\r
13 * Exception-handling code using PHP5 exceptions (try-catch-throw).
\r
16 if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
\r
17 define('ADODB_ERROR_HANDLER','adodb_throw');
\r
19 class ADODB_Exception extends Exception {
\r
27 function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
\r
32 $this->params = $p2;
\r
33 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
\r
38 $user = $thisConnection->user;
\r
39 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n";
\r
42 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
\r
46 $this->dbms = $dbms;
\r
47 $this->host = $thisConnection->host;
\r
48 $this->database = $thisConnection->database;
\r
50 $this->msg = $errmsg;
\r
52 if (!is_numeric($errno)) $errno = -1;
\r
53 parent::__construct($s,$errno);
\r
58 * Default Error Handler. This will be called with the following params
\r
60 * @param $dbms the RDBMS you are connecting to
\r
61 * @param $fn the name of the calling function (in uppercase)
\r
62 * @param $errno the native error number from the database
\r
63 * @param $errmsg the native error msg from the database
\r
64 * @param $p1 $fn specific parameter - see below
\r
65 * @param $P2 $fn specific parameter - see below
\r
68 function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
\r
70 global $ADODB_EXCEPTION;
\r
72 if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
\r
73 else $errfn = 'ADODB_EXCEPTION';
\r
74 throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
\r