Parcourir la source

replace error message with Error object

Brian Gough il y a 8 ans
Parent
commit
c652abf739

+ 2 - 6
services/web/app/coffee/Features/Editor/EditorHttpController.coffee

@@ -128,12 +128,8 @@ module.exports = EditorHttpController =
 		folder_id = req.body.folder_id
 		user_id = AuthenticationController.getLoggedInUserId(req)
 		EditorController.moveEntity project_id, entity_id, folder_id, entity_type, user_id, (error) ->
-			if error?.message == 'destination folder is a child folder of me'
-				res.status(400).json(req.i18n.translate('invalid_file_name'))
-			else if error?
-				next(error)
-			else
-				res.sendStatus 204
+			return next(error) if error?
+			res.sendStatus 204
 
 	deleteDoc: (req, res, next)->
 		req.params.entity_type  = "doc"

+ 1 - 1
services/web/app/coffee/Features/Project/ProjectEntityHandler.coffee

@@ -426,7 +426,7 @@ module.exports = ProjectEntityHandler =
 					logger.log destFolderPath: destFolderPath.fileSystem, folderPath: entityPath.fileSystem, "checking folder is not moving into child folder"
 					isNestedFolder = destFolderPath.fileSystem.slice(0, entityPath.fileSystem.length) == entityPath.fileSystem
 					if isNestedFolder
-						return callback(new Error("destination folder is a child folder of me"))
+						return callback(new Errors.InvalidNameError("destination folder is a child folder of me"))
 				callback()
 
 	deleteEntity: (project_id, entity_id, entityType, userId, callback = (error) ->)->