3 * Moodle - Modular Object-Oriented Dynamic Learning Environment
5 * Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @subpackage portfolio
22 * @author Penny Leach <penny@catalyst.net.nz>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
24 * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
26 * This file contains all the portfolio exception classes.
29 defined('MOODLE_INTERNAL') || die();
32 * top level portfolio exception.
33 * sometimes caught and rethrown as {@see portfolio_export_exception}
35 class portfolio_exception extends moodle_exception {}
38 * exception to throw during an export - will clean up session and tempdata
40 class portfolio_export_exception extends portfolio_exception {
44 * @param object $exporter instance of portfolio_exporter (will handle null case)
45 * @param string $errorcode language string key
46 * @param string $module language string module (optional, defaults to moodle)
47 * @param string $continue url to continue to (optional, defaults to wwwroot)
48 * @param mixed $a language string data (optional, defaults to null)
50 public function __construct($exporter, $errorcode, $module=null, $continue=null, $a=null) {
52 // This static variable is necessary because sometimes the code below
53 // which tries to obtain a continue link can cause one of these
54 // exceptions to be thrown. This would create an infinite loop (until
55 // PHP hits its stack limit). Using this static lets us make the
56 // nested constructor finish immediately without attempting to call
57 // methods that might fail.
58 static $inconstructor = false;
60 if (!$inconstructor && !empty($exporter) &&
61 $exporter instanceof portfolio_exporter) {
62 $inconstructor = true;
64 if (empty($continue)) {
65 $caller = $exporter->get('caller');
66 if (!empty($caller) && $caller instanceof portfolio_caller_base) {
67 $continue = $exporter->get('caller')->get_return_url();
70 // this was previously only called if we were in cron,
71 // but I think if there's always an exception, we should clean up
72 // rather than force the user to resolve the export later.
73 $exporter->process_stage_cleanup();
74 } catch(Exception $e) {
75 // Ooops, we had an exception trying to get caller
76 // information. Ignore it.
78 $inconstructor = false;
80 parent::__construct($errorcode, $module, $continue, $a);
85 * exception for callers to throw when they have a problem.
86 * usually caught and rethrown as {@see portfolio_export_exception}
88 class portfolio_caller_exception extends portfolio_exception {}
91 * exception for portfolio plugins to throw when they have a problem.
92 * usually caught and rethrown as {@see portfolio_export_exception}
94 class portfolio_plugin_exception extends portfolio_exception {}
97 * exception for interacting with the button class
99 class portfolio_button_exception extends portfolio_exception {}
102 * leap2a exception - for invalid api calls
104 class portfolio_format_leap2a_exception extends portfolio_exception {}