Update scripts

This commit is contained in:
Nick Cipollo
2019-12-12 18:46:17 -05:00
parent 7319d490c8
commit 455687cd65
6 changed files with 85 additions and 17 deletions

View File

@@ -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");
}