diff --git a/src/addon/mod/resource/components/index/index.ts b/src/addon/mod/resource/components/index/index.ts index 2304a319e..2c1283958 100644 --- a/src/addon/mod/resource/components/index/index.ts +++ b/src/addon/mod/resource/components/index/index.ts @@ -15,6 +15,7 @@ import { Component, Injector } from '@angular/core'; import { CoreAppProvider } from '@providers/app'; import { CoreSitesProvider } from '@providers/sites'; +import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component'; import { AddonModResourceProvider } from '../../providers/resource'; @@ -38,7 +39,8 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource constructor(injector: Injector, private resourceProvider: AddonModResourceProvider, private courseProvider: CoreCourseProvider, private appProvider: CoreAppProvider, private prefetchHandler: AddonModResourcePrefetchHandler, - private resourceHelper: AddonModResourceHelperProvider, private sitesProvider: CoreSitesProvider) { + private resourceHelper: AddonModResourceHelperProvider, private sitesProvider: CoreSitesProvider, + private utils: CoreUtilsProvider) { super(injector); } @@ -78,7 +80,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource // Load module contents if needed. Passing refresh is needed to force reloading contents. return this.courseProvider.loadModuleContents(this.module, this.courseId, null, false, refresh).then(() => { if (!this.module.contents || !this.module.contents.length) { - return Promise.reject(null); + return Promise.reject(this.utils.createFakeWSError('core.filenotfound', true)); } // Get the resource instance to get the latest name/description and to know if it's embedded. diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 8fd9e1499..8e7ff5128 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1342,6 +1342,7 @@ "core.favourites": "Starred", "core.filename": "Filename", "core.filenameexist": "File name already exists: {{$a}}", + "core.filenotfound": "File not found, sorry.", "core.fileuploader.addfiletext": "Add file", "core.fileuploader.audio": "Audio", "core.fileuploader.camera": "Camera", diff --git a/src/core/course/providers/helper.ts b/src/core/course/providers/helper.ts index aa57300b6..a79546849 100644 --- a/src/core/course/providers/helper.ts +++ b/src/core/course/providers/helper.ts @@ -528,7 +528,7 @@ export class CoreCourseHelperProvider { // Make sure that module contents are loaded. return promise.then(() => { if (!files || !files.length) { - return Promise.reject(null); + return Promise.reject(this.utils.createFakeWSError('core.filenotfound', true)); } return this.sitesProvider.getSite(siteId); diff --git a/src/lang/en.json b/src/lang/en.json index 3df5da21b..27e5e170f 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -95,6 +95,7 @@ "favourites": "Starred", "filename": "Filename", "filenameexist": "File name already exists: {{$a}}", + "filenotfound": "File not found, sorry.", "folder": "Folder", "forcepasswordchangenotice": "You must change your password to proceed.", "fulllistofcourses": "All courses",