4 * @version v5.20.16 12-Jan-2020
5 * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
6 * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
7 * Released under both BSD license and Lesser GPL library license.
8 * Whenever there is any discrepancy between the two licenses,
9 * the BSD license will take precedence.
11 * Set tabs to 4 for best viewing.
13 * Latest version is available at http://adodb.org/
15 * Exception-handling code using PHP5 exceptions (try-catch-throw).
19 if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR
);
20 define('ADODB_ERROR_HANDLER','adodb_throw');
22 class ADODB_Exception
extends Exception
{
30 function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
34 $this->sql
= is_array($p1) ?
$p1[0] : $p1;
36 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$this->sql\")";
41 $user = $thisConnection->user
;
42 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)";
45 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
50 if ($thisConnection) {
51 $this->host
= $thisConnection->host
;
52 $this->database
= $thisConnection->database
;
57 if (!is_numeric($errno)) $errno = -1;
58 parent
::__construct($s,$errno);
63 * Default Error Handler. This will be called with the following params
65 * @param $dbms the RDBMS you are connecting to
66 * @param $fn the name of the calling function (in uppercase)
67 * @param $errno the native error number from the database
68 * @param $errmsg the native error msg from the database
69 * @param $p1 $fn specific parameter - see below
70 * @param $P2 $fn specific parameter - see below
73 function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
75 global $ADODB_EXCEPTION;
77 if (error_reporting() == 0) return; // obey @ protocol
78 if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
79 else $errfn = 'ADODB_EXCEPTION';
80 throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);