From f125a755bf3a7c818c7e6ff50beac8f8ab9aff28 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Thu, 5 Jul 2018 12:13:07 +0100 Subject: [PATCH] Add a new error type to LinkedFiles: FileCannotRefreshError --- .../Features/LinkedFiles/LinkedFilesController.coffee | 7 ++++++- .../Features/LinkedFiles/LinkedFilesErrors.coffee | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee b/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee index 9f5c380fb8..03c4e6c975 100644 --- a/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee +++ b/services/web/app/coffee/Features/LinkedFiles/LinkedFilesController.coffee @@ -17,7 +17,8 @@ LinkedFilesHandler = require './LinkedFilesHandler' SourceFileNotFoundError, NotOriginalImporterError, FeatureNotAvailableError, - RemoteServiceError + RemoteServiceError, + FileCannotRefreshError } = require './LinkedFilesErrors' Modules = require '../../infrastructure/Modules' @@ -138,6 +139,10 @@ module.exports = LinkedFilesController = { "The remote service produced an error" ) + else if error instanceof FileCannotRefreshError + res.status(400).send( + "This file cannot be refreshed" + ) else next(error) diff --git a/services/web/app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee b/services/web/app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee index e7ea63e563..96509c91f1 100644 --- a/services/web/app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee +++ b/services/web/app/coffee/Features/LinkedFiles/LinkedFilesErrors.coffee @@ -94,6 +94,14 @@ RemoteServiceError = (message) -> RemoteServiceError.prototype.__proto__ = Error.prototype +FileCannotRefreshError = (message) -> + error = new Error(message) + error.name = 'RemoteService' + error.__proto__ = FileCannotRefreshError.prototype + return error +FileCannotRefreshError.prototype.__proto__ = Error.prototype + + module.exports = { UrlFetchFailedError, @@ -107,5 +115,6 @@ module.exports = { SourceFileNotFoundError, NotOriginalImporterError, FeatureNotAvailableError, - RemoteServiceError + RemoteServiceError, + FileCannotRefreshError }