MOBILE-3847 mod: Improve error message when module not found

main
Dani Palou 2021-08-26 11:22:53 +02:00
parent 2175a11dbb
commit 28056bf176
25 changed files with 40 additions and 37 deletions

View File

@ -1497,6 +1497,7 @@
"core.course.insufficientavailablequota": "local_moodlemobileapp", "core.course.insufficientavailablequota": "local_moodlemobileapp",
"core.course.insufficientavailablespace": "local_moodlemobileapp", "core.course.insufficientavailablespace": "local_moodlemobileapp",
"core.course.manualcompletionnotsynced": "local_moodlemobileapp", "core.course.manualcompletionnotsynced": "local_moodlemobileapp",
"core.course.modulenotfound": "local_moodlemobileapp",
"core.course.nocontentavailable": "local_moodlemobileapp", "core.course.nocontentavailable": "local_moodlemobileapp",
"core.course.overriddennotice": "grades", "core.course.overriddennotice": "grades",
"core.course.refreshcourse": "local_moodlemobileapp", "core.course.refreshcourse": "local_moodlemobileapp",

View File

@ -17,7 +17,7 @@ import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@
import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreInterceptor } from '@classes/interceptor'; import { CoreInterceptor } from '@classes/interceptor';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws'; import { CoreWSExternalWarning, CoreWSExternalFile, CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { CoreGrades } from '@features/grades/services/grades'; import { CoreGrades } from '@features/grades/services/grades';
@ -218,7 +218,7 @@ export class AddonModAssignProvider {
} }
} }
throw new CoreError('Assignment not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -17,7 +17,7 @@ import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreTagItem } from '@features/tag/services/tag'; import { CoreTagItem } from '@features/tag/services/tag';
import { CoreWSExternalWarning, CoreWSExternalFile, CoreWS } from '@services/ws'; import { CoreWSExternalWarning, CoreWSExternalFile, CoreWS } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreCourseLogHelper } from '@features/course/services/log-helper'; import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course'; import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
@ -103,7 +103,7 @@ export class AddonModBookProvider {
return book; return book;
} }
throw new CoreError('Book not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -61,7 +61,7 @@ export class AddonModChatProvider {
return chat; return chat;
} }
throw new CoreError('Chat not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -23,7 +23,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { AddonModChoiceOffline } from './choice-offline'; import { AddonModChoiceOffline } from './choice-offline';
import { AddonModChoiceAutoSyncData, AddonModChoiceSyncProvider } from './choice-sync'; import { AddonModChoiceAutoSyncData, AddonModChoiceSyncProvider } from './choice-sync';
@ -215,7 +215,7 @@ export class AddonModChoiceProvider {
return currentChoice; return currentChoice;
} }
throw new CoreError('Choice not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -25,7 +25,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { AddonModDataFieldsDelegate } from './data-fields-delegate'; import { AddonModDataFieldsDelegate } from './data-fields-delegate';
import { AddonModDataOffline } from './data-offline'; import { AddonModDataOffline } from './data-offline';
import { AddonModDataAutoSyncData, AddonModDataSyncProvider } from './data-sync'; import { AddonModDataAutoSyncData, AddonModDataSyncProvider } from './data-sync';
@ -586,7 +586,7 @@ export class AddonModDataProvider {
return currentData; return currentData;
} }
throw new CoreError('Activity not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -22,7 +22,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning, CoreWSStoredFile } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning, CoreWSStoredFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { AddonModFeedbackOffline } from './feedback-offline'; import { AddonModFeedbackOffline } from './feedback-offline';
import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync'; import { AddonModFeedbackAutoSyncData, AddonModFeedbackSyncProvider } from './feedback-sync';
@ -605,7 +605,7 @@ export class AddonModFeedbackProvider {
return currentFeedback; return currentFeedback;
} }
throw new CoreError('Feedback not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -20,7 +20,7 @@ import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
const ROOT_CACHE_KEY = 'mmaModFolder:'; const ROOT_CACHE_KEY = 'mmaModFolder:';
@ -80,7 +80,7 @@ export class AddonModFolderProvider {
return currentFolder; return currentFolder;
} }
throw new CoreError('Folder not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper'; import { CoreCourseLogHelper } from '@features/course/services/log-helper';
@ -480,7 +481,7 @@ export class AddonModForumProvider {
const forum = forums.find(forum => forum.cmid == cmId); const forum = forums.find(forum => forum.cmid == cmId);
if (!forum) { if (!forum) {
throw new Error('Forum not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
return forum; return forum;

View File

@ -811,7 +811,7 @@ export class AddonModGlossaryProvider {
return glossary; return glossary;
} }
throw new CoreError('Glossary not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**
@ -835,7 +835,7 @@ export class AddonModGlossaryProvider {
return glossary; return glossary;
} }
throw new CoreError('Glossary not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -528,7 +528,7 @@ export class AddonModH5PActivityProvider {
return currentActivity; return currentActivity;
} }
throw new CoreError(Translate.instant('addon.mod_h5pactivity.errorgetactivity')); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -24,7 +24,7 @@ import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text'; import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
const ROOT_CACHE_KEY = 'mmaModImscp:'; const ROOT_CACHE_KEY = 'mmaModImscp:';
@ -183,7 +183,7 @@ export class AddonModImscpProvider {
return currentImscp; return currentImscp;
} }
throw new CoreError('Imscp not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -19,7 +19,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
const ROOT_CACHE_KEY = 'mmaModLabel:'; const ROOT_CACHE_KEY = 'mmaModLabel:';
@ -77,7 +77,7 @@ export class AddonModLabelProvider {
return currentLabel; return currentLabel;
} }
throw new CoreError('Label not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -1445,7 +1445,7 @@ export class AddonModLessonProvider {
return currentLesson; return currentLesson;
} }
throw new CoreError('Lesson not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -110,7 +110,7 @@ export class AddonModLtiProvider {
return currentLti; return currentLti;
} }
throw new CoreError('Activity not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites'; import { CoreSitesCommonWSOptions, CoreSites } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws'; import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreFilepool } from '@services/filepool'; import { CoreFilepool } from '@services/filepool';
import { CoreCourse } from '@features/course/services/course'; import { CoreCourse } from '@features/course/services/course';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
@ -79,7 +79,7 @@ export class AddonModPageProvider {
return currentPage; return currentPage;
} }
throw new CoreError('Page not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -748,7 +748,7 @@ export class AddonModQuizProvider {
const quiz = response.quizzes.find(quiz => quiz[key] == value); const quiz = response.quizzes.find(quiz => quiz[key] == value);
if (!quiz) { if (!quiz) {
throw new CoreError('Quiz not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
return quiz; return quiz;

View File

@ -21,7 +21,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
const ROOT_CACHE_KEY = 'mmaModResource:'; const ROOT_CACHE_KEY = 'mmaModResource:';
@ -82,7 +82,7 @@ export class AddonModResourceProvider {
return currentResource; return currentResource;
} }
throw new CoreError('Resource not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -1105,7 +1105,7 @@ export class AddonModScormProvider {
const currentScorm = <AddonModScormScorm> response.scorms.find(scorm => scorm[key] == value); const currentScorm = <AddonModScormScorm> response.scorms.find(scorm => scorm[key] == value);
if (!currentScorm) { if (!currentScorm) {
throw new CoreError('SCORM not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
// If the SCORM isn't available the WS returns a warning and it doesn't return timeopen and timeclosed. // If the SCORM isn't available the WS returns a warning and it doesn't return timeopen and timeclosed.

View File

@ -22,7 +22,7 @@ import { CoreFilepool } from '@services/filepool';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreStatusWithWarningsWSResponse, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { AddonModSurveyOffline } from './survey-offline'; import { AddonModSurveyOffline } from './survey-offline';
const ROOT_CACHE_KEY = 'mmaModSurvey:'; const ROOT_CACHE_KEY = 'mmaModSurvey:';
@ -121,7 +121,7 @@ export class AddonModSurveyProvider {
return currentSurvey; return currentSurvey;
} }
throw new CoreError('Activity not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites'; import { CoreSites, CoreSitesCommonWSOptions } from '@services/sites';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws'; import { CoreWSExternalWarning, CoreWSExternalFile } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreConstants } from '@/core/constants'; import { CoreConstants } from '@/core/constants';
import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreMimetypeUtils } from '@services/utils/mimetype';
import { CoreCourse } from '@features/course/services/course'; import { CoreCourse } from '@features/course/services/course';
@ -131,7 +131,7 @@ export class AddonModUrlProvider {
return currentUrl; return currentUrl;
} }
throw new CoreError('Url not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -397,7 +397,7 @@ export class AddonModWikiProvider {
return currentWiki; return currentWiki;
} }
throw new CoreError('Wiki not found.'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**

View File

@ -23,7 +23,7 @@ import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@
import { CoreTextFormat, defaultTextFormat } from '@services/utils/text'; import { CoreTextFormat, defaultTextFormat } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws'; import { CoreStatusWithWarningsWSResponse, CoreWS, CoreWSExternalFile, CoreWSExternalWarning } from '@services/ws';
import { makeSingleton } from '@singletons'; import { makeSingleton, Translate } from '@singletons';
import { CoreFormFields } from '@singletons/form'; import { CoreFormFields } from '@singletons/form';
import { AddonModWorkshopOffline } from './workshop-offline'; import { AddonModWorkshopOffline } from './workshop-offline';
import { AddonModWorkshopAutoSyncData, AddonModWorkshopSyncProvider } from './workshop-sync'; import { AddonModWorkshopAutoSyncData, AddonModWorkshopSyncProvider } from './workshop-sync';
@ -272,7 +272,7 @@ export class AddonModWorkshopProvider {
const workshop = response.workshops.find((workshop) => workshop[key] == value); const workshop = response.workshops.find((workshop) => workshop[key] == value);
if (!workshop) { if (!workshop) {
throw new CoreError('Activity not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
// Set submission types for Moodle 3.5 and older. // Set submission types for Moodle 3.5 and older.

View File

@ -41,6 +41,7 @@
"insufficientavailablespace": "You are trying to download {{size}}. This will leave your device with insufficient space to operate normally. Please clear some storage space first.", "insufficientavailablespace": "You are trying to download {{size}}. This will leave your device with insufficient space to operate normally. Please clear some storage space first.",
"insufficientavailablequota": "Your device could not allocate space to save this download. It may be reserving space for app and system updates. Please clear some storage space first.", "insufficientavailablequota": "Your device could not allocate space to save this download. It may be reserving space for app and system updates. Please clear some storage space first.",
"manualcompletionnotsynced": "Manual completion not synchronised.", "manualcompletionnotsynced": "Manual completion not synchronised.",
"modulenotfound": "Resource or activity not found, please make sure you're online and it's still available.",
"nocontentavailable": "No content available at the moment.", "nocontentavailable": "No content available at the moment.",
"overriddennotice": "Your final grade from this activity was manually adjusted.", "overriddennotice": "Your final grade from this activity was manually adjusted.",
"refreshcourse": "Refresh course", "refreshcourse": "Refresh course",

View File

@ -505,7 +505,7 @@ export class CoreCourseProvider {
return foundModule; return foundModule;
} }
throw Error('Module not found'); throw new CoreError(Translate.instant('core.course.modulenotfound'));
} }
/** /**