-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
node_modules/ | ||
#node_modules/ | ||
__tests__/runner/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const GithubError_1 = require("./GithubError"); | ||
class ErrorMessage { | ||
constructor(error) { | ||
this.error = error; | ||
} | ||
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() { | ||
const errors = this.error.errors; | ||
if (errors instanceof Array) { | ||
return errors.map((err) => new GithubError_1.GithubError(err)); | ||
} | ||
else { | ||
return []; | ||
} | ||
} | ||
errorBulletedList(errors) { | ||
return errors.map((err) => `- ${err}`).join("\n"); | ||
} | ||
} | ||
exports.ErrorMessage = ErrorMessage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class GithubError { | ||
constructor(error) { | ||
this.error = error; | ||
} | ||
toString() { | ||
const code = this.error.code; | ||
switch (code) { | ||
case 'missing': | ||
return this.missingResourceMessage(); | ||
case 'missing_field': | ||
return this.missingFieldMessage(); | ||
case 'invalid': | ||
return this.invalidFieldMessage(); | ||
case 'already_exists': | ||
return this.resourceAlreadyExists(); | ||
default: | ||
return this.customErrorMessage(); | ||
} | ||
} | ||
customErrorMessage() { | ||
const message = this.error.message; | ||
const documentation = this.error.documentation_url; | ||
let documentationMessage; | ||
if (documentation) { | ||
documentationMessage = `\nPlease see ${documentation}.`; | ||
} | ||
else { | ||
documentationMessage = ""; | ||
} | ||
return `${message}${documentationMessage}`; | ||
} | ||
invalidFieldMessage() { | ||
const resource = this.error.resource; | ||
const field = this.error.field; | ||
return `The ${field} field on ${resource} is an invalid format.`; | ||
} | ||
missingResourceMessage() { | ||
const resource = this.error.resource; | ||
return `${resource} does not exist.`; | ||
} | ||
missingFieldMessage() { | ||
const resource = this.error.resource; | ||
const field = this.error.field; | ||
return `The ${field} field on ${resource} is missing.`; | ||
} | ||
resourceAlreadyExists() { | ||
const resource = this.error.resource; | ||
return `${resource} already exists.`; | ||
} | ||
} | ||
exports.GithubError = GithubError; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.