Merge branch 'wip-mdl-48190-m27' of https://github.com/rajeshtaneja/moodle into MOODL...
[moodle.git] / lib / filestorage / file_exceptions.php
blob61304f80a6de87b1cfa2ea7bdf4f8423c4c909e5
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 * File handling related exceptions.
20 * @package core_files
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();
27 /**
28 * Basic file related exception class.
30 * @package core_files
31 * @category files
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 {
36 /**
37 * Constructor
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);
48 /**
49 * Can not create file exception.
51 * @package core_files
52 * @category files
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 {
57 /**
58 * Constructor.
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) {
69 $a = new stdClass();
70 $a->contextid = $contextid;
71 $a->component = $component;
72 $a->filearea = $filearea;
73 $a->itemid = $itemid;
74 $a->filepath = $filepath;
75 $a->filename = $filename;
76 parent::__construct('storedfilenotcreated', $a, $debuginfo);
80 /**
81 * No file access exception.
83 * @package core_files
84 * @category files
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 {
89 /**
90 * Constructor.
92 * @param string $debuginfo extra debug info
94 public function __construct($debuginfo = null) {
95 parent::__construct('nopermissions', null, $debuginfo);
99 /**
100 * Hash file content problem exception.
102 * @package core_files
103 * @category 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 {
109 * Constructor.
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
124 * @category 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 {
130 * Constructor.
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) {
139 $a = new stdClass();
140 $a->repositoryid = $repositoryid;
141 $a->reference = $reference;
142 $a->referencefileid = $referencefileid;
143 $a->fileid = $fileid;
144 parent::__construct('filereferenceproblem', $a, $debuginfo);