mirror of https://github.com/zulip/zulip.git
zblueslip: Show chained causes in unexpected messages.
This commit is contained in:
parent
fa92895731
commit
5d97dbf8b3
|
@ -85,12 +85,12 @@ function make_zblueslip() {
|
|||
for (const name of names) {
|
||||
if (!opts[name]) {
|
||||
// should just log the message.
|
||||
lib[name] = function (message, more_info, stack) {
|
||||
lib.test_logs[name].push({message, more_info, stack});
|
||||
lib[name] = function (message, more_info, cause) {
|
||||
lib.test_logs[name].push({message, more_info, cause});
|
||||
};
|
||||
continue;
|
||||
}
|
||||
lib[name] = function (message, more_info, stack) {
|
||||
lib[name] = function (message, more_info, cause) {
|
||||
/* istanbul ignore if */
|
||||
if (typeof message !== "string") {
|
||||
// We may catch exceptions in blueslip, and if
|
||||
|
@ -101,12 +101,16 @@ function make_zblueslip() {
|
|||
throw new Error("message should be string: " + message);
|
||||
}
|
||||
}
|
||||
lib.test_logs[name].push({message, more_info, stack});
|
||||
lib.test_logs[name].push({message, more_info, cause});
|
||||
const matched_error_message = lib.test_data[name].find((x) => x.message === message);
|
||||
const exact_match_fail = !matched_error_message;
|
||||
if (exact_match_fail) {
|
||||
const error = new Error(`Invalid ${name} message: "${message}".`);
|
||||
error.blueslip = true;
|
||||
/* istanbul ignore if */
|
||||
if (cause !== undefined) {
|
||||
error.cause = cause;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue