jenkins-bot has submitted this change and it was merged.
Change subject: Move stack suppression to the logger
......................................................................
Move stack suppression to the logger
* Leave the stack untouched so that it is still available for uses
outside the logger (such as in node's default console display for
uncaught exceptions).
* Follows I41658e7823392dc398e15a4e48d9e8a3b3ef9934
Change-Id: I60b2c6f19689d3ddf1c3ed4542170ac672e063a5
---
M api/routes.js
M api/utils.js
M lib/LogData.js
M lib/mediawiki.ApiRequest.js
4 files changed, 11 insertions(+), 10 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/api/routes.js b/api/routes.js
index 90a6d2f..7071e3e 100644
--- a/api/routes.js
+++ b/api/routes.js
@@ -29,7 +29,7 @@
var errOut = function(res, text, code) {
var err = new Error(text);
err.code = code || 404;
- err.stack = null;
+ err.suppressLoggingStack = true;
processLogger.log('fatal/request', err);
apiUtils.sendResponse(res, {}, text, err.code);
};
diff --git a/api/utils.js b/api/utils.js
index 2968be3..9347e76 100644
--- a/api/utils.js
+++ b/api/utils.js
@@ -164,7 +164,7 @@
apiUtils.timeoutResp = function(env, err) {
if (err instanceof Promise.TimeoutError) {
err = new Error('Request timed out.');
- err.stack = null;
+ err.suppressLoggingStack = true;
}
env.log('fatal/request', err);
};
@@ -552,7 +552,7 @@
if (!dp || !dp.body || dp.body.constructor !== Object || !dp.body.ids) {
var err = new Error('Invalid data-parsoid was provided.');
err.code = 400;
- err.stack = null;
+ err.suppressLoggingStack = true;
throw err;
}
};
@@ -568,6 +568,6 @@
apiUtils.fatalRequest = function(env, text, code) {
var err = new Error(text);
err.code = code || 404;
- err.stack = null;
+ err.suppressLoggingStack = true;
env.log('fatal/request', err);
};
diff --git a/lib/LogData.js b/lib/LogData.js
index 1553d11..460553a 100644
--- a/lib/LogData.js
+++ b/lib/LogData.js
@@ -142,10 +142,11 @@
} else if (o instanceof Error) {
f = {
msg: o.message,
- // In some cases, stacks are suppressed (See
DoesNotExistError in
- // mediawikiApiRequest.js). We return a defined value
to avoid
- // generating a stack above.
- stack: o.stack || "",
+ // In some cases, we wish to suppress stacks when
logging,
+ // as indicated by `suppressLoggingStack`.
+ // (E.g. see DoesNotExistError in
mediawikiApiRequest.js).
+ // We return a defined value to avoid generating a
stack above.
+ stack: o.suppressLoggingStack ? "" : o.stack,
};
if (o.code) {
f.code = o.code;
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index 93dfb21..ef183ea 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -164,7 +164,7 @@
this.name = "DoesNotExistError";
this.message = message || "Something doesn't exist";
this.code = 404;
- this.stack = null; // suppress stack
+ this.suppressLoggingStack = true;
}
DoesNotExistError.prototype = Error.prototype;
@@ -930,7 +930,7 @@
} else {
error = this._errorObj(data, '',
'No result.\n' + JSON.stringify(data, '\t', 2));
- error.stack = null;
+ error.suppressLoggingStack = true;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/245998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I60b2c6f19689d3ddf1c3ed4542170ac672e063a5
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits