MDL-78165 mod_bigbluebuttonbn: Fetch cron status using API
[moodle.git] / lib / adodb / adodb-exceptions.inc.php
blob560286a1847175491011c99b5acb870af136a0d8
1 <?php
2 /**
3 * Error handling using Exceptions.
5 * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
7 * @package ADOdb
8 * @link https://adodb.org Project's web site and documentation
9 * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
11 * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
12 * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
13 * any later version. This means you can use it in proprietary products.
14 * See the LICENSE.md file distributed with this source code for details.
15 * @license BSD-3-Clause
16 * @license LGPL-2.1-or-later
18 * @copyright 2000-2013 John Lim
19 * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
22 if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
23 define('ADODB_ERROR_HANDLER','adodb_throw');
25 class ADODB_Exception extends Exception {
26 var $dbms;
27 var $fn;
28 var $sql = '';
29 var $params = '';
30 var $host = '';
31 var $database = '';
33 function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
35 switch($fn) {
36 case 'EXECUTE':
37 $this->sql = is_array($p1) ? $p1[0] : $p1;
38 $this->params = $p2;
39 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$this->sql\")";
40 break;
42 case 'PCONNECT':
43 case 'CONNECT':
44 $user = $thisConnection->user;
45 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)";
46 break;
47 default:
48 //Prevent PHP warning if $p1 or $p2 are arrays.
49 $p1 = ( is_array($p1) ) ? 'Array' : $p1;
50 $p2 = ( is_array($p2) ) ? 'Array' : $p2;
51 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
52 break;
55 $this->dbms = $dbms;
56 if ($thisConnection) {
57 $this->host = $thisConnection->host;
58 $this->database = $thisConnection->database;
60 $this->fn = $fn;
61 $this->msg = $errmsg;
63 if (!is_numeric($errno)) $errno = -1;
64 parent::__construct($s,$errno);
68 /**
69 * Default Error Handler.
71 * @param string $dbms the RDBMS you are connecting to
72 * @param string $fn the name of the calling function (in uppercase)
73 * @param int $errno the native error number from the database
74 * @param string $errmsg the native error msg from the database
75 * @param mixed $p1 $fn specific parameter - see below
76 * @param mixed $p2 $fn specific parameter - see below
79 function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
81 global $ADODB_EXCEPTION;
83 if (error_reporting() == 0) return; // obey @ protocol
84 if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
85 else $errfn = 'ADODB_EXCEPTION';
86 throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);