$string['invalidsesskey'] = 'Incorrect sesskey submitted, form not accepted!';
$string['invalidsection'] = 'Course module record contains invalid section';
$string['invalidshortname'] = 'That\'s an invalid short course name';
+$string['invalidstatedetected'] = 'Something has gone wrong: $a. This should never normally happen.';
$string['invalidurl'] = 'Invalid URL';
$string['invaliduser'] = 'Invalid user';
$string['invaliduserid'] = 'Invalid user id';
}
/**
- * Exception indicating programming error, must be fixed by a programer.
+ * Exception indicating programming error, must be fixed by a programer. For example
+ * a core API might throw this type of exception if a plugin calls it incorrectly.
*/
class coding_exception extends moodle_exception {
-
/**
* Constructor
* @param string $hint short description of problem
}
}
+/**
+ * An exception that indicates something really weird happended. For example,
+ * if you do switch ($context->contextlevel), and have one case for each
+ * CONTEXT_... constant. You might throw an invalid_state_exception in the
+ * default case, to just in case something really weird is going on, and
+ * $context->contextlevel is invalid - ratehr than ignoring this possibility.
+ */
+class invalid_state_exception extends moodle_exception {
+ /**
+ * Constructor
+ * @param string $hint short description of problem
+ * @param string $debuginfo optional more detailed information
+ */
+ function __construct($hint, $debuginfo=null) {
+ parent::__construct('invalidstatedetected', 'debug', '', $hint, $debuginfo);
+ }
+}
+
/**
* Default exception handler, uncought exceptions are equivalent to using print_error()
*/