improve unified pipeline error display (#60)
* improve error * fix test case * add cutoffMsg Co-authored-by: jianyexi <jianyxi@microsoft.com>
This commit is contained in:
Родитель
6cc02cbb5a
Коммит
ef487b4315
|
@ -269,12 +269,12 @@ export async function runScript() {
|
|||
const errorResult: format.MessageLine = errors.map((it) => ({
|
||||
type: "Raw",
|
||||
level: "Error",
|
||||
message: it.error.stack || "",
|
||||
message: "Runtime Exception",
|
||||
time: new Date(),
|
||||
extra: {
|
||||
role: "Breaking change",
|
||||
new: it.new,
|
||||
old: it.old,
|
||||
details: utils.cutoffMsg(it.error.stack) || "",
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ class LinterRunner {
|
|||
);
|
||||
if (parser.hasAutoRestError()) {
|
||||
this.pushError({
|
||||
type: "AutoRestErr",
|
||||
type: "AutoRest Exception",
|
||||
code: "",
|
||||
message: parser.getAutoRestError(),
|
||||
readme: spec,
|
||||
|
@ -174,7 +174,7 @@ class LinterRunner {
|
|||
}
|
||||
} catch (err) {
|
||||
this.pushError({
|
||||
type: "RuntimeErrors",
|
||||
type: "Runtime Exception",
|
||||
code: err.code,
|
||||
message: err.message,
|
||||
readmeUrl: this.getReadmeUrl(beforeOrAfter, swagger),
|
||||
|
@ -214,7 +214,7 @@ class LinterRunner {
|
|||
if (errMsg && errMsg.length > 10) {
|
||||
errMsg = errMsg.slice(0,10)
|
||||
}
|
||||
error.message = errMsg ? errMsg.join("") : ""
|
||||
error.message = errMsg ? utils.cutoffMsg(errMsg.join("")) : "";
|
||||
this.errors.push(error);
|
||||
}
|
||||
}
|
||||
|
@ -273,10 +273,10 @@ export async function lintDiff(utils: TypeUtils, devOps: TypeDevOps) {
|
|||
const errorResult: format.MessageLine = linter.getError().map((it) => ({
|
||||
type: "Raw",
|
||||
level: "Error",
|
||||
message: it.message || "",
|
||||
message: it.type || "",
|
||||
time: new Date(),
|
||||
extra: {
|
||||
role: it.type,
|
||||
details: it.message,
|
||||
location: it.readmeUrl,
|
||||
},
|
||||
}));
|
||||
|
|
|
@ -189,7 +189,7 @@ class MomentOfTruthTest {
|
|||
|
||||
assert.equal(errors.length, 2);
|
||||
assert.equal(
|
||||
errors[0].message.indexOf('{ "Channel": "fatal",') !== -1,
|
||||
errors[0].extra.details.indexOf('{ "Channel": "fatal",') !== -1,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
|
@ -800,4 +800,11 @@ export function targetHref(file: string) {
|
|||
export function blobHref(file: unknown) {
|
||||
const repoName = process.env.TRAVIS_PULL_REQUEST_SLUG !== undefined ? process.env.TRAVIS_PULL_REQUEST_SLUG : process.env.TRAVIS_REPO_SLUG;
|
||||
return `https://github.com/${repoName}/blob/${process.env.TRAVIS_PULL_REQUEST_SHA}/${file}`;
|
||||
}
|
||||
|
||||
export function cutoffMsg(msg: string | undefined, size: number = 1024):string {
|
||||
if (!msg || msg.length <= size) {
|
||||
return msg ? msg : "";
|
||||
}
|
||||
return msg.substr(0, size);
|
||||
}
|
Загрузка…
Ссылка в новой задаче