Fixes #6 Add support for updating releases

This commit is contained in:
Nick Cipollo
2019-12-12 17:09:21 -05:00
parent de74298134
commit 7319d490c8
12 changed files with 297 additions and 51 deletions

View File

@@ -1,23 +1,15 @@
import { GithubError } from "./GithubError"
export class ErrorMessage {
error: any
private error: any
private githubErrors: GithubError[]
constructor(error: any) {
this.error = error
this.githubErrors = this.generateGithubErrors()
}
toString(): string {
const message = this.error.message
const errors = this.githubErrors()
if (errors.length > 0) {
return `${message}\nErrors:\n${this.errorBulletedList(errors)}`
} else {
return message
}
}
githubErrors(): GithubError[] {
private generateGithubErrors(): GithubError[] {
const errors = this.error.errors
if (errors instanceof Array) {
return errors.map((err) => new GithubError(err))
@@ -26,7 +18,21 @@ export class ErrorMessage {
}
}
errorBulletedList(errors: GithubError[]): string {
hasErrorWithCode(code: String): boolean {
return this.githubErrors.some((err) => err.code == code)
}
toString(): string {
const message = this.error.message
const errors = this.githubErrors
if (errors.length > 0) {
return `${message}\nErrors:\n${this.errorBulletedList(errors)}`
} else {
return message
}
}
private errorBulletedList(errors: GithubError[]): string {
return errors.map((err) => `- ${err}`).join("\n")
}
}