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:
@@ -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';
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user