Automatically generated installer lang files
[moodle.git] / lib / adodb / adodb-exceptions.inc.php
blob77d16f2fd4f32b4a20c9d85304deff2883859353
1 <?php
3 /**
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 {
23 var $dbms;
24 var $fn;
25 var $sql = '';
26 var $params = '';
27 var $host = '';
28 var $database = '';
30 function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
32 switch($fn) {
33 case 'EXECUTE':
34 $this->sql = is_array($p1) ? $p1[0] : $p1;
35 $this->params = $p2;
36 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$this->sql\")";
37 break;
39 case 'PCONNECT':
40 case 'CONNECT':
41 $user = $thisConnection->user;
42 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)";
43 break;
44 default:
45 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
46 break;
49 $this->dbms = $dbms;
50 if ($thisConnection) {
51 $this->host = $thisConnection->host;
52 $this->database = $thisConnection->database;
54 $this->fn = $fn;
55 $this->msg = $errmsg;
57 if (!is_numeric($errno)) $errno = -1;
58 parent::__construct($s,$errno);
62 /**
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);