MDL-58535 repository_onedrive: Better error

When OneDrive has never been initialised the Graph API returns an error. Detect this and
direct the user to log in to OneDrive.
This commit is contained in:
Damyon Wiese
2017-05-01 16:15:36 +08:00
parent 8381b05d49
commit c0a4efdce2
2 changed files with 3 additions and 2 deletions
@@ -34,6 +34,7 @@ $string['importskydrivefiles'] = 'Import files from Microsoft SkyDrive repositor
$string['internal'] = 'Internal (files stored in Moodle)';
$string['issuer_help'] = 'Select the OAuth 2 service that is configured to talk to the OneDrive API. If the services does not exist yet, you might need to create it.';
$string['issuer'] = 'OAuth 2 service';
$string['mysitenotfound'] = 'You have never logged into OneDrive before. You must login to OneDrive at least once it before it can be used with Moodle.';
$string['oauth2serviceslink'] = '<a href="{$a}" title="Link to OAuth Services configuration">OAuth 2 Services Configuration</a>';
$string['owner'] = 'Owned by: {$a}';
$string['pluginname'] = 'Microsoft OneDrive';
+2 -2
View File
@@ -311,8 +311,8 @@ class repository_onedrive extends repository {
} catch (Exception $e) {
if ($e->getCode() == 403 && strpos($e->getMessage(), 'Access Not Configured') !== false) {
throw new repository_exception('servicenotenabled', 'repository_onedrive');
} else {
throw $e;
} else if (strpos($e->getMessage(), 'mysite not found') !== false) {
throw new repository_exception('mysitenotfound', 'repository_onedrive');
}
}