Commit f8f14870 authored by Francois Marier's avatar Francois Marier

Exceptions: use the right MaharaException class

In order to provide useful debugging information to users and
admins, make use of the right MaharaException subclass.
Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent cde0dd94
......@@ -143,7 +143,7 @@ class PluginAuthImap extends PluginAuth {
if ($instance > 0) {
$current = get_records_array('auth_instance', 'id', $instance, 'priority ASC');
if ($current == false) {
throw new Exception('Could not find data for auth instance '.$instance);
throw new SystemException('Could not find data for auth instance '.$instance);
}
$default = $current[0];
$current_config = get_records_menu('auth_instance_config', 'instance', $instance, '', 'field, value');
......
......@@ -898,8 +898,7 @@ function requiredfields_submit(Pieform $form, $values) {
$SESSION->add_ok_msg(get_string('passwordsaved'));
}
else {
// TODO: Exception is the wrong type here!
throw new Exception('Attempt by "' . $USER->get('username') . '@'
throw new SystemException('Attempt by "' . $USER->get('username') . '@'
. $USER->get('institution') . 'to change their password failed');
}
}
......
......@@ -202,7 +202,7 @@ function forgotpasschange_submit(Pieform $form, $values) {
$user = new User();
$user->find_by_id($values['user']);
} catch (AuthUnknownUserException $e) {
throw new Exception('Request to change the password for a user who does not exist');
throw new UserException('Request to change the password for a user who does not exist');
}
$authobj = AuthFactory::create($user->authinstance);
......@@ -217,7 +217,7 @@ function forgotpasschange_submit(Pieform $form, $values) {
exit;
}
throw new Exception('User "' . $user->username
throw new SystemException('User "' . $user->username
. ' tried to change their password, but the attempt failed');
}
......
......@@ -270,7 +270,7 @@ function activity_locate_typerecord($activitytype, $plugintype=null, $pluginname
}
}
if (empty($at)) {
throw new Exception("Invalid activity type $activitytype");
throw new SystemException("Invalid activity type $activitytype");
}
return $at;
}
......
......@@ -174,7 +174,7 @@ class Institution {
function commit() {
if (!$this->verifyReady()) {
throw new Exception();
throw new SystemException('Commit failed');
}
$record = new stdClass();
......
......@@ -1037,7 +1037,7 @@ function check_dir_exists($dir, $create=true, $recursive=true) {
function safe_require($plugintype, $pluginname, $filename='lib.php', $function='require_once', $nonfatal=false) {
$plugintypes = plugin_types();
if (!in_array($plugintype, $plugintypes)) {
throw new Exception("\"$plugintype\" is not a valid plugin type");
throw new SystemException("\"$plugintype\" is not a valid plugin type");
}
require_once(get_config('docroot') . $plugintype . '/lib.php');
......@@ -1045,7 +1045,7 @@ function safe_require($plugintype, $pluginname, $filename='lib.php', $function='
if (!empty($nonfatal)) {
return false;
}
throw new Exception ('invalid require type');
throw new SystemException ('Invalid require type');
}
if ($plugintype == 'blocktype') { // these are a bit of a special case
......@@ -1218,7 +1218,7 @@ function blocktype_name_to_namespaced($blocktype) {
*/
function handle_event($event, $data) {
if (!$e = get_record('event_type', 'name', $event)) {
throw new Exception("Invalid event");
throw new SystemException("Invalid event");
}
if ($data instanceof ArtefactType || $data instanceof BlockInstance) {
......
......@@ -513,7 +513,7 @@ function search_friend($filter, $limit, $offset) {
$userid = $USER->get('id');
if (!in_array($filter, array('all','current','pending'))) {
throw new Exception();
throw new SystemException('Invalid search filter');
}
$sql = array();
......
......@@ -97,8 +97,7 @@ if (isset($key)) {
$authinstance = get_record('auth_instance', 'institution', $registration->institution, 'authname', 'internal');
if (false == $authinstance) {
// TODO: Specify exception
throw new Exception('No internal auth instance for institution');
throw new ConfigException('No internal auth instance for institution');
}
$user = new User();
......
......@@ -626,7 +626,7 @@ END;
$url = get_config_plugin('search', 'solr', 'solrurl') . 'select';
if (!$client->submit($url, $data)) {
throw new Exception('Request to solr failed');
throw new SystemException('Request to solr failed');
}
if( $client->status != 200 ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment