Update scripts
This commit is contained in:
@@ -4,18 +4,9 @@ const GithubError_1 = require("./GithubError");
|
||||
class ErrorMessage {
|
||||
constructor(error) {
|
||||
this.error = error;
|
||||
this.githubErrors = this.generateGithubErrors();
|
||||
}
|
||||
toString() {
|
||||
const message = this.error.message;
|
||||
const errors = this.githubErrors();
|
||||
if (errors.length > 0) {
|
||||
return `${message}\nErrors:\n${this.errorBulletedList(errors)}`;
|
||||
}
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
githubErrors() {
|
||||
generateGithubErrors() {
|
||||
const errors = this.error.errors;
|
||||
if (errors instanceof Array) {
|
||||
return errors.map((err) => new GithubError_1.GithubError(err));
|
||||
@@ -24,6 +15,19 @@ class ErrorMessage {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
hasErrorWithCode(code) {
|
||||
return this.githubErrors.some((err) => err.code == code);
|
||||
}
|
||||
toString() {
|
||||
const message = this.error.message;
|
||||
const errors = this.githubErrors;
|
||||
if (errors.length > 0) {
|
||||
return `${message}\nErrors:\n${this.errorBulletedList(errors)}`;
|
||||
}
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
errorBulletedList(errors) {
|
||||
return errors.map((err) => `- ${err}`).join("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user