Logging and error message tweaks

This commit is contained in:
James Allen 2018-03-01 11:32:05 +00:00
parent d4025908b7
commit d92c3e8b55
2 changed files with 4 additions and 3 deletions

View file

@ -24,6 +24,7 @@ module.exports = LinkedFilesController = {
linkedFileData.provider = provider
Agent.writeIncomingFileToDisk project_id, linkedFileData, user_id, (error, fsPath) ->
if error?
logger.error {err: error, project_id, name, linkedFileData, parent_folder_id, user_id}, 'error writing linked file to disk'
return Agent.handleError(error, req, res, next)
EditorController.upsertFile project_id, parent_folder_id, name, fsPath, linkedFileData, "upload", user_id, (error) ->
return next(error) if error?

View file

@ -31,15 +31,15 @@ module.exports = UrlAgent = {
callback = _.once(callback)
url = data.url
if !urlValidator.isWebUri(url)
return callback(new InvalidUrlError())
url = @._wrapWithProxy(url)
return callback(new InvalidUrlError("invalid url: #{url}"))
url = UrlAgent._wrapWithProxy(url)
readStream = request.get(url)
readStream.on "error", callback
readStream.on "response", (response) ->
if 200 <= response.statusCode < 300
FileWriter.writeStreamToDisk project_id, readStream, callback
else
error = new UrlFetchFailedError()
error = new UrlFetchFailedError("url fetch failed: #{url}")
error.statusCode = response.statusCode
callback(error)