kopia lustrzana https://github.com/c9/core
do not show ENOENT errors in browser console
rodzic
c7c3325a7c
commit
c044ca14f5
|
@ -10,7 +10,9 @@ module.exports = function setup(mount, vfs, mountOptions) {
|
||||||
if (!mountOptions) mountOptions = {};
|
if (!mountOptions) mountOptions = {};
|
||||||
|
|
||||||
var errorHandler = mountOptions.errorHandler || function (req, res, err, code) {
|
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) {
|
if (res.headersSent) {
|
||||||
res.end("");
|
res.end("");
|
||||||
return;
|
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 (typeof err.code == "number" && isValidStatusCode(err.code)) res.statusCode = err.code;
|
||||||
else if (err.code === "EBADREQUEST") res.statusCode = 400;
|
else if (err.code === "EBADREQUEST") res.statusCode = 400;
|
||||||
else if (err.code === "EACCES") res.statusCode = 403;
|
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 === "ENOTREADY") res.statusCode = 503;
|
||||||
else if (err.code === "EISDIR") res.statusCode = 503;
|
else if (err.code === "EISDIR") res.statusCode = 503;
|
||||||
else res.statusCode = 500;
|
else res.statusCode = 500;
|
||||||
|
|
|
@ -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);
|
var err = new Error(xhr.responseText);
|
||||||
err.code = xhr.status;
|
err.code = xhr.status;
|
||||||
if (debug)
|
if (debug && xhr.status > 299)
|
||||||
console.error("HTTP error " + this.status + ": " + xhr.responseText);
|
console.error("HTTP error " + xhr.status + ": " + xhr.responseText);
|
||||||
return done(err, data, res);
|
return done(err, data, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue