diff --git a/services/filestore/app/coffee/FileController.coffee b/services/filestore/app/coffee/FileController.coffee index 876227c029..2b10419fb2 100644 --- a/services/filestore/app/coffee/FileController.coffee +++ b/services/filestore/app/coffee/FileController.coffee @@ -46,6 +46,9 @@ module.exports = FileController = {key, bucket} = req logger.log key:key, bucket:bucket, "reciving request to insert file" FileHandler.insertFile bucket, key, req, (err)-> + if err? + logger.log err: err, key: key, bucket: bucket, "error inserting file" + res.send 500 res.send 200 copyFile: (req, res)-> diff --git a/services/filestore/app/coffee/FileHandler.coffee b/services/filestore/app/coffee/FileHandler.coffee index e49c172c92..698e311ca2 100644 --- a/services/filestore/app/coffee/FileHandler.coffee +++ b/services/filestore/app/coffee/FileHandler.coffee @@ -38,6 +38,8 @@ module.exports = _getConvertedFile: (bucket, key, opts, callback)-> convetedKey = KeyBuilder.addCachingToKey(key, opts) PersistorManager.checkIfFileExists bucket, convetedKey, (err, exists)=> + if err? + return callback(err) if exists PersistorManager.getFileStream bucket, convetedKey, opts, callback else @@ -62,6 +64,8 @@ module.exports = _convertFile: (bucket, origonalKey, opts, callback)-> @_writeS3FileToDisk bucket, origonalKey, opts, (err, origonalFsPath)-> + if err? + return callback(err) done = (err, destPath)-> if err? logger.err err:err, bucket:bucket, origonalKey:origonalKey, opts:opts, "error converting file" @@ -76,7 +80,7 @@ module.exports = else if opts.style == "preview" FileConverter.preview origonalFsPath, done else - throw new Error("should have specified opts to convert file with #{JSON.stringify(opts)}") + return callback(new Error("should have specified opts to convert file with #{JSON.stringify(opts)}")) _writeS3FileToDisk: (bucket, key, opts, callback)->