From c044ca14f5121ca67583855cd7f53ba1008d9f95 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 27 Feb 2017 19:02:39 +0400 Subject: [PATCH] do not show ENOENT errors in browser console --- node_modules/vfs-http-adapter/restful.js | 6 ++++-- plugins/c9.core/http-xhr.js | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/node_modules/vfs-http-adapter/restful.js b/node_modules/vfs-http-adapter/restful.js index 3bf1646b..79166442 100644 --- a/node_modules/vfs-http-adapter/restful.js +++ b/node_modules/vfs-http-adapter/restful.js @@ -10,7 +10,9 @@ module.exports = function setup(mount, vfs, mountOptions) { if (!mountOptions) mountOptions = {}; var errorHandler = mountOptions.errorHandler || function (req, res, err, code) { - console.error(err.stack || err); + // do not show ENOENT errors in browser console + if (err.code != "ENOENT") + console.error(err.stack || err); if (res.headersSent) { res.end(""); return; @@ -20,7 +22,7 @@ module.exports = function setup(mount, vfs, mountOptions) { else if (typeof err.code == "number" && isValidStatusCode(err.code)) res.statusCode = err.code; else if (err.code === "EBADREQUEST") res.statusCode = 400; else if (err.code === "EACCES") res.statusCode = 403; - else if (err.code === "ENOENT") res.statusCode = 404; + else if (err.code === "ENOENT") res.statusCode = 208; else if (err.code === "ENOTREADY") res.statusCode = 503; else if (err.code === "EISDIR") res.statusCode = 503; else res.statusCode = 500; diff --git a/plugins/c9.core/http-xhr.js b/plugins/c9.core/http-xhr.js index 378d68af..66285110 100644 --- a/plugins/c9.core/http-xhr.js +++ b/plugins/c9.core/http-xhr.js @@ -119,11 +119,11 @@ define(function(require, module, exports) { } } - if (this.status > 299) { + if (xhr.status > 299 || xhr.status == 208) { var err = new Error(xhr.responseText); err.code = xhr.status; - if (debug) - console.error("HTTP error " + this.status + ": " + xhr.responseText); + if (debug && xhr.status > 299) + console.error("HTTP error " + xhr.status + ": " + xhr.responseText); return done(err, data, res); }