Automatically generated installer lang files
[moodle.git] / lib / portfolio / exceptions.php
blobba2ca56c0d4a4167edeca22fd779082bb1b5ad1d
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * This file contains all the portfolio exception classes.
20 * @package core_portfolio
21 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>, Martin Dougiamas
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 /**
28 * Top level portfolio exception.
30 * Sometimes caught and re-thrown as portfolio_export_exception
31 * @see portfolio_export_exception
33 * @package core_portfolio
34 * @category portfolio
35 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class portfolio_exception extends moodle_exception {}
40 /**
41 * Exception to throw during an export - will clean up session and tempdata
43 * @package core_portfolio
44 * @category portfolio
45 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>
46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
48 class portfolio_export_exception extends portfolio_exception {
50 /**
51 * Constructor.
53 * @param portfolio_exporter $exporter instance of portfolio_exporter (will handle null case)
54 * @param string $errorcode language string key
55 * @param string $module language string module (optional, defaults to moodle)
56 * @param string $continue url to continue to (optional, defaults to wwwroot)
57 * @param object $a language string data (optional, defaults to null)
59 public function __construct($exporter, $errorcode, $module=null, $continue=null, $a=null) {
60 global $CFG;
61 // This static variable is necessary because sometimes the code below
62 // which tries to obtain a continue link can cause one of these
63 // exceptions to be thrown. This would create an infinite loop (until
64 // PHP hits its stack limit). Using this static lets us make the
65 // nested constructor finish immediately without attempting to call
66 // methods that might fail.
67 static $inconstructor = false;
69 if (!$inconstructor && !empty($exporter) &&
70 $exporter instanceof portfolio_exporter) {
71 $inconstructor = true;
72 try {
73 if (empty($continue)) {
74 $caller = $exporter->get('caller');
75 if (!empty($caller) && $caller instanceof portfolio_caller_base) {
76 $continue = $exporter->get('caller')->get_return_url();
79 // this was previously only called if we were in cron,
80 // but I think if there's always an exception, we should clean up
81 // rather than force the user to resolve the export later.
82 $exporter->process_stage_cleanup();
83 } catch(Exception $e) {
84 // Ooops, we had an exception trying to get caller
85 // information. Ignore it.
87 $inconstructor = false;
89 parent::__construct($errorcode, $module, $continue, $a);
93 /**
94 * Exception for callers to throw when they have a problem.
96 * Usually caught and rethrown as portfolio_export_exception
97 * @see portfolio_export_exception
99 * @package core_portfolio
100 * @category portfolio
101 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>
102 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
104 class portfolio_caller_exception extends portfolio_exception {}
107 * Exception for portfolio plugins to throw when they have a problem.
109 * Usually caught and rethrown as portfolio_export_exception
110 * @see portfolio_export_exception
112 * @package core_portfolio
113 * @category portfolio
114 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>
115 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
117 class portfolio_plugin_exception extends portfolio_exception {}
120 * Exception for interacting with the button class
122 * @package core_portfolio
123 * @category portfolio
124 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>
125 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
127 class portfolio_button_exception extends portfolio_exception {}
130 * Leap2a exception - for invalid api calls
132 * @package core_portfolio
133 * @category portfolio
134 * @copyright 2008 Penny Leach <penny@catalyst.net.nz>
135 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
137 class portfolio_format_leap2a_exception extends portfolio_exception {}