2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
18 * File handling related exceptions.
21 * @copyright 2008 Petr Skoda (http://skodak.org)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
28 * Basic file related exception class.
32 * @copyright 2008 Petr Skoda (http://skodak.org)
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class file_exception
extends moodle_exception
{
39 * @param string $errorcode error code
40 * @param stdClass $a Extra words and phrases that might be required in the error string
41 * @param string $debuginfo optional debugging information
43 function __construct($errorcode, $a=NULL, $debuginfo = NULL) {
44 parent
::__construct($errorcode, '', '', $a, $debuginfo);
49 * Cannot create file exception.
53 * @copyright 2008 Petr Skoda (http://skodak.org)
54 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
56 class stored_file_creation_exception
extends file_exception
{
60 * @param int $contextid context ID
61 * @param string $component component
62 * @param string $filearea file area
63 * @param int $itemid item ID
64 * @param string $filepath file path
65 * @param string $filename file name
66 * @param string $debuginfo extra debug info
68 function __construct($contextid, $component, $filearea, $itemid, $filepath, $filename, $debuginfo = null) {
70 $a->contextid
= $contextid;
71 $a->component
= $component;
72 $a->filearea
= $filearea;
74 $a->filepath
= $filepath;
75 $a->filename
= $filename;
76 parent
::__construct('storedfilenotcreated', $a, $debuginfo);
81 * No file access exception.
85 * @copyright 2008 Petr Skoda (http://skodak.org)
86 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
88 class file_access_exception
extends file_exception
{
92 * @param string $debuginfo extra debug info
94 public function __construct($debuginfo = null) {
95 parent
::__construct('nopermissions', null, $debuginfo);
100 * Hash file content problem exception.
102 * @package core_files
104 * @copyright 2008 Petr Skoda (http://skodak.org)
105 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
107 class file_pool_content_exception
extends file_exception
{
111 * @param string $contenthash content hash
112 * @param string $debuginfo extra debug info
114 public function __construct($contenthash, $debuginfo = null) {
115 parent
::__construct('hashpoolproblem', $contenthash, $debuginfo);
121 * Problem with records in the {files_reference} table.
123 * @package core_files
125 * @copyright 2012 David Mudrak <david@moodle.com>
126 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
128 class file_reference_exception
extends file_exception
{
132 * @param int $repositoryid the id of the repository that provides the referenced file
133 * @param string $reference the information for the repository to locate the file
134 * @param int|null $referencefileid the id of the record in {files_reference} if known
135 * @param int|null $fileid the id of the referrer's record in {files} if known
136 * @param string|null $debuginfo extra debug info
138 function __construct($repositoryid, $reference, $referencefileid=null, $fileid=null, $debuginfo=null) {
140 $a->repositoryid
= $repositoryid;
141 $a->reference
= $reference;
142 $a->referencefileid
= $referencefileid;
143 $a->fileid
= $fileid;
144 parent
::__construct('filereferenceproblem', $a, $debuginfo);