From 8f0b206fd3bfed01c574d4012e58b1d62ff5ff44 Mon Sep 17 00:00:00 2001 From: Nick Cipollo Date: Tue, 23 Mar 2021 16:15:29 -0400 Subject: [PATCH] Cleanup error classes and CI --- .github/workflows/build.yml | 28 ++++++ .github/workflows/checkin.yml | 25 ----- .github/workflows/test.yml | 14 +++ __tests__/ErrorMessage.test.ts | 70 -------------- __tests__/GithubError.test.ts | 145 +++++++++++----------------- __tests__/GithubErrorDetail.test.ts | 98 +++++++++++++++++++ __tests__/Integration.test.ts | 2 +- lib/Action.js | 6 +- lib/ErrorMessage.js | 40 -------- lib/GithubError.js | 63 +++++------- lib/GithubErrorDetail.js | 57 +++++++++++ lib/Main.js | 8 +- src/Action.ts | 6 +- src/ErrorMessage.ts | 44 --------- src/GithubError.ts | 79 ++++++--------- src/GithubErrorDetail.ts | 65 +++++++++++++ src/Main.ts | 6 +- 17 files changed, 386 insertions(+), 370 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/checkin.yml create mode 100644 .github/workflows/test.yml delete mode 100644 __tests__/ErrorMessage.test.ts create mode 100644 __tests__/GithubErrorDetail.test.ts delete mode 100644 lib/ErrorMessage.js create mode 100644 lib/GithubErrorDetail.js delete mode 100644 src/ErrorMessage.ts create mode 100644 src/GithubErrorDetail.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..439bc31 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: "PR Checks" +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + check_pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: "yarn install" + run: yarn install + + - name: "yarn build" + run: yarn build + + - name: "check for uncommitted changes" + # Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed. + run: | + git diff --exit-code --stat -- . ':!node_modules' \ + || (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \ + "and check in all changes" \ + && exit 1) diff --git a/.github/workflows/checkin.yml b/.github/workflows/checkin.yml deleted file mode 100644 index c57ded9..0000000 --- a/.github/workflows/checkin.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "PR Checks" -on: [pull_request, push] - -jobs: - check_pr: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - - name: "yarn install" - run: yarn install - - - name: "yarn build" - run: yarn build - - - name: "yarn test" - run: yarn test - - - name: "check for uncommitted changes" - # Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed. - run: | - git diff --exit-code --stat -- . ':!node_modules' \ - || (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \ - "and check in all changes" \ - && exit 1) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..903115e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,14 @@ +name: "Test" +on: [push, pull_request] + +jobs: + check_pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - name: "yarn install" + run: yarn install + + - name: "yarn test" + run: yarn test \ No newline at end of file diff --git a/__tests__/ErrorMessage.test.ts b/__tests__/ErrorMessage.test.ts deleted file mode 100644 index ce0dfc8..0000000 --- a/__tests__/ErrorMessage.test.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ErrorMessage } from "../src/ErrorMessage" - -describe('ErrorMessage', () => { - - describe('has error with code', () => { - const error = { - message: 'something bad happened', - errors: [ - { - code: 'missing', - resource: 'release' - }, - { - code: 'already_exists', - resource: 'release' - } - ], - status: 422 - } - - it('does not have error', () => { - const errorMessage = new ErrorMessage(error) - expect(errorMessage.hasErrorWithCode('missing_field')).toBeFalsy() - }) - - it('has error', () => { - const errorMessage = new ErrorMessage(error) - expect(errorMessage.hasErrorWithCode('missing')).toBeTruthy() - }) - }) - - it('generates message with errors', () => { - const error = { - message: 'something bad happened', - errors: [ - { - code: 'missing', - resource: 'release' - }, - { - code: 'already_exists', - resource: 'release' - } - ], - status: 422 - } - - const errorMessage = new ErrorMessage(error) - - const expectedString = "Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists." - expect(errorMessage.toString()).toBe(expectedString) - }) - - it('generates message without errors', () => { - const error = { - message: 'something bad happened', - status: 422 - } - - const errorMessage = new ErrorMessage(error) - - expect(errorMessage.toString()).toBe('Error 422: something bad happened') - }) - - it('provides error status', () => { - const error = { status: 404 } - const errorMessage = new ErrorMessage(error) - expect(errorMessage.status).toBe(404) - }) -}) diff --git a/__tests__/GithubError.test.ts b/__tests__/GithubError.test.ts index 657a756..3daddfd 100644 --- a/__tests__/GithubError.test.ts +++ b/__tests__/GithubError.test.ts @@ -1,99 +1,70 @@ import { GithubError } from "../src/GithubError" -describe('GithubError', () => { +describe('ErrorMessage', () => { - it('provides error code', () => { + describe('has error with code', () => { const error = { - code: "missing" + message: 'something bad happened', + errors: [ + { + code: 'missing', + resource: 'release' + }, + { + code: 'already_exists', + resource: 'release' + } + ], + status: 422 } - const githubError = new GithubError(error) - - expect(githubError.code).toBe('missing') - }) - - it('generates missing resource error message', () => { - const resource = "release" - const error = { - code: "missing", - resource: resource - } - - const githubError = new GithubError(error) - const message = githubError.toString() - - expect(message).toBe(`${resource} does not exist.`) - }) - - it('generates missing field error message', () => { - const resource = "release" - const field = "body" - const error = { - code: "missing_field", - field: field, - resource: resource - } - - const githubError = new GithubError(error) - const message = githubError.toString() - - expect(message).toBe(`The ${field} field on ${resource} is missing.`) - }) - - it('generates invalid field error message', () => { - const resource = "release" - const field = "body" - const error = { - code: "invalid", - field: field, - resource: resource - } - - const githubError = new GithubError(error) - const message = githubError.toString() - - expect(message).toBe(`The ${field} field on ${resource} is an invalid format.`) - }) - - it('generates resource already exists error message', () => { - const resource = "release" - const field = "body" - const error = { - code: "already_exists", - resource: resource - } - - const githubError = new GithubError(error) - const message = githubError.toString() - - expect(message).toBe(`${resource} already exists.`) - }) - - describe('generates custom error message', () => { - it('with documentation url', () => { - const url = "https://api.example.com" - const error = { - code: "custom", - message: "foo", - documentation_url: url - } - + it('does not have error', () => { const githubError = new GithubError(error) - const message = githubError.toString() - - expect(message).toBe(`foo\nPlease see ${url}.`) + expect(githubError.hasErrorWithCode('missing_field')).toBeFalsy() }) - it('without documentation url', () => { - const error = { - code: "custom", - message: "foo" - } - + it('has error', () => { const githubError = new GithubError(error) - const message = githubError.toString() - - expect(message).toBe('foo') + expect(githubError.hasErrorWithCode('missing')).toBeTruthy() }) }) -}) \ No newline at end of file + + it('generates message with errors', () => { + const error = { + message: 'something bad happened', + errors: [ + { + code: 'missing', + resource: 'release' + }, + { + code: 'already_exists', + resource: 'release' + } + ], + status: 422 + } + + const githubError = new GithubError(error) + + const expectedString = "Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists." + expect(githubError.toString()).toBe(expectedString) + }) + + it('generates message without errors', () => { + const error = { + message: 'something bad happened', + status: 422 + } + + const githubError = new GithubError(error) + + expect(githubError.toString()).toBe('Error 422: something bad happened') + }) + + it('provides error status', () => { + const error = { status: 404 } + const githubError = new GithubError(error) + expect(githubError.status).toBe(404) + }) +}) diff --git a/__tests__/GithubErrorDetail.test.ts b/__tests__/GithubErrorDetail.test.ts new file mode 100644 index 0000000..ed4ab61 --- /dev/null +++ b/__tests__/GithubErrorDetail.test.ts @@ -0,0 +1,98 @@ +import { GithubErrorDetail } from "../src/GithubErrorDetail" + +describe('GithubErrorDetail', () => { + + it('provides error code', () => { + const error = { + code: "missing" + } + + const detail = new GithubErrorDetail(error) + + expect(detail.code).toBe('missing') + }) + + it('generates missing resource error message', () => { + const resource = "release" + const error = { + code: "missing", + resource: resource + } + + const detail = new GithubErrorDetail(error) + const message = detail.toString() + + expect(message).toBe(`${resource} does not exist.`) + }) + + it('generates missing field error message', () => { + const resource = "release" + const field = "body" + const error = { + code: "missing_field", + field: field, + resource: resource + } + + const detail = new GithubErrorDetail(error) + const message = detail.toString() + + expect(message).toBe(`The ${field} field on ${resource} is missing.`) + }) + + it('generates invalid field error message', () => { + const resource = "release" + const field = "body" + const error = { + code: "invalid", + field: field, + resource: resource + } + + const detail = new GithubErrorDetail(error) + const message = detail.toString() + + expect(message).toBe(`The ${field} field on ${resource} is an invalid format.`) + }) + + it('generates resource already exists error message', () => { + const resource = "release" + const error = { + code: "already_exists", + resource: resource + } + + const detail = new GithubErrorDetail(error) + const message = detail.toString() + + expect(message).toBe(`${resource} already exists.`) + }) + + describe('generates custom error message', () => { + it('with documentation url', () => { + const url = "https://api.example.com" + const error = { + code: "custom", + message: "foo", + documentation_url: url + } + + const detail = new GithubErrorDetail(error) + const message = detail.toString() + + expect(message).toBe(`foo\nPlease see ${url}.`) + }) + + it('without documentation url', () => { + const error = { + code: "custom", + message: "foo" + } + + const detail = new GithubErrorDetail(error) + const message = detail.toString() + + expect(message).toBe('foo') + }) + }) +}) \ No newline at end of file diff --git a/__tests__/Integration.test.ts b/__tests__/Integration.test.ts index 16c2063..a7f8950 100644 --- a/__tests__/Integration.test.ts +++ b/__tests__/Integration.test.ts @@ -20,8 +20,8 @@ describe.skip('Integration Test', () => { const releases = new GithubReleases(inputs, git) const uploader = new GithubArtifactUploader( releases, + inputs.replacesArtifacts, inputs.artifactErrorsFailBuild, - inputs.replacesArtifacts ) action = new Action(inputs, releases, uploader) }) diff --git a/lib/Action.js b/lib/Action.js index 00d4b2f..83ca0b1 100644 --- a/lib/Action.js +++ b/lib/Action.js @@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Action = void 0; -const ErrorMessage_1 = require("./ErrorMessage"); +const GithubError_1 = require("./GithubError"); class Action { constructor(inputs, releases, uploader) { this.inputs = inputs; @@ -55,8 +55,8 @@ class Action { }); } static noPublishedRelease(error) { - const errorMessage = new ErrorMessage_1.ErrorMessage(error); - return errorMessage.status == 404; + const githubError = new GithubError_1.GithubError(error); + return githubError.status == 404; } updateDraftOrCreateRelease() { return __awaiter(this, void 0, void 0, function* () { diff --git a/lib/ErrorMessage.js b/lib/ErrorMessage.js deleted file mode 100644 index 95f36f1..0000000 --- a/lib/ErrorMessage.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ErrorMessage = void 0; -const GithubError_1 = require("./GithubError"); -class ErrorMessage { - constructor(error) { - this.error = error; - this.githubErrors = this.generateGithubErrors(); - } - generateGithubErrors() { - const errors = this.error.errors; - if (errors instanceof Array) { - return errors.map((err) => new GithubError_1.GithubError(err)); - } - else { - return []; - } - } - get status() { - return this.error.status; - } - hasErrorWithCode(code) { - return this.githubErrors.some((err) => err.code == code); - } - toString() { - const message = this.error.message; - const errors = this.githubErrors; - const status = this.status; - if (errors.length > 0) { - return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}`; - } - else { - return `Error ${status}: ${message}`; - } - } - errorBulletedList(errors) { - return errors.map((err) => `- ${err}`).join("\n"); - } -} -exports.ErrorMessage = ErrorMessage; diff --git a/lib/GithubError.js b/lib/GithubError.js index 9a1851b..2edcddc 100644 --- a/lib/GithubError.js +++ b/lib/GithubError.js @@ -1,57 +1,40 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GithubError = void 0; +const GithubErrorDetail_1 = require("./GithubErrorDetail"); class GithubError { constructor(error) { this.error = error; + this.githubErrors = this.generateGithubErrors(); } - get code() { - return this.error.code; - } - 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}.`; + generateGithubErrors() { + const errors = this.error.errors; + if (errors instanceof Array) { + return errors.map((err) => new GithubErrorDetail_1.GithubErrorDetail(err)); } else { - documentationMessage = ""; + return []; } - return `${message}${documentationMessage}`; } - invalidFieldMessage() { - const resource = this.error.resource; - const field = this.error.field; - return `The ${field} field on ${resource} is an invalid format.`; + get status() { + return this.error.status; } - missingResourceMessage() { - const resource = this.error.resource; - return `${resource} does not exist.`; + hasErrorWithCode(code) { + return this.githubErrors.some((err) => err.code == code); } - missingFieldMessage() { - const resource = this.error.resource; - const field = this.error.field; - return `The ${field} field on ${resource} is missing.`; + toString() { + const message = this.error.message; + const errors = this.githubErrors; + const status = this.status; + if (errors.length > 0) { + return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}`; + } + else { + return `Error ${status}: ${message}`; + } } - resourceAlreadyExists() { - const resource = this.error.resource; - return `${resource} already exists.`; + errorBulletedList(errors) { + return errors.map((err) => `- ${err}`).join("\n"); } } exports.GithubError = GithubError; diff --git a/lib/GithubErrorDetail.js b/lib/GithubErrorDetail.js new file mode 100644 index 0000000..ccff073 --- /dev/null +++ b/lib/GithubErrorDetail.js @@ -0,0 +1,57 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GithubErrorDetail = void 0; +class GithubErrorDetail { + constructor(error) { + this.error = error; + } + get code() { + return this.error.code; + } + 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.GithubErrorDetail = GithubErrorDetail; diff --git a/lib/Main.js b/lib/Main.js index 044531f..583468b 100644 --- a/lib/Main.js +++ b/lib/Main.js @@ -35,7 +35,7 @@ const Releases_1 = require("./Releases"); const Action_1 = require("./Action"); const ArtifactUploader_1 = require("./ArtifactUploader"); const ArtifactGlobber_1 = require("./ArtifactGlobber"); -const ErrorMessage_1 = require("./ErrorMessage"); +const GithubError_1 = require("./GithubError"); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -43,8 +43,8 @@ function run() { yield action.perform(); } catch (error) { - const errorMessage = new ErrorMessage_1.ErrorMessage(error); - core.setFailed(errorMessage.toString()); + const githubError = new GithubError_1.GithubError(error); + core.setFailed(githubError.toString()); } }); } @@ -55,7 +55,7 @@ function createAction() { const globber = new ArtifactGlobber_1.FileArtifactGlobber(); const inputs = new Inputs_1.CoreInputs(globber, context); const releases = new Releases_1.GithubReleases(inputs, git); - const uploader = new ArtifactUploader_1.GithubArtifactUploader(releases, inputs.replacesArtifacts); + const uploader = new ArtifactUploader_1.GithubArtifactUploader(releases, inputs.replacesArtifacts, inputs.artifactErrorsFailBuild); return new Action_1.Action(inputs, releases, uploader); } run(); diff --git a/src/Action.ts b/src/Action.ts index a8ba2b2..4144117 100644 --- a/src/Action.ts +++ b/src/Action.ts @@ -1,7 +1,7 @@ import {Inputs} from "./Inputs"; import {CreateReleaseResponse, Releases, UpdateReleaseResponse} from "./Releases"; import {ArtifactUploader} from "./ArtifactUploader"; -import {ErrorMessage} from "./ErrorMessage"; +import {GithubError} from "./GithubError"; export class Action { private inputs: Inputs @@ -55,8 +55,8 @@ export class Action { } private static noPublishedRelease(error: any): boolean { - const errorMessage = new ErrorMessage(error) - return errorMessage.status == 404 + const githubError = new GithubError(error) + return githubError.status == 404 } private async updateDraftOrCreateRelease(): Promise { diff --git a/src/ErrorMessage.ts b/src/ErrorMessage.ts deleted file mode 100644 index 9d90c83..0000000 --- a/src/ErrorMessage.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {GithubError} from "./GithubError" - -export class ErrorMessage { - private error: any - private githubErrors: GithubError[] - - constructor(error: any) { - this.error = error - this.githubErrors = this.generateGithubErrors() - } - - private generateGithubErrors(): GithubError[] { - const errors = this.error.errors - if (errors instanceof Array) { - return errors.map((err) => new GithubError(err)) - } else { - return [] - } - } - - get status(): number { - return this.error.status - } - - hasErrorWithCode(code: String): boolean { - return this.githubErrors.some((err) => err.code == code) - } - - toString(): string { - const message = this.error.message - const errors = this.githubErrors - const status = this.status - if (errors.length > 0) { - return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}` - } else { - return `Error ${status}: ${message}` - } - } - - private errorBulletedList(errors: GithubError[]): string { - return errors.map((err) => `- ${err}`).join("\n") - } -} - diff --git a/src/GithubError.ts b/src/GithubError.ts index be2d29b..3967d6d 100644 --- a/src/GithubError.ts +++ b/src/GithubError.ts @@ -1,65 +1,44 @@ +import {GithubErrorDetail} from "./GithubErrorDetail" + export class GithubError { - private error: any; + private error: any + private readonly githubErrors: GithubErrorDetail[] constructor(error: any) { this.error = error + this.githubErrors = this.generateGithubErrors() } - get code(): string { - return this.error.code + private generateGithubErrors(): GithubErrorDetail[] { + const errors = this.error.errors + if (errors instanceof Array) { + return errors.map((err) => new GithubErrorDetail(err)) + } else { + return [] + } + } + + get status(): number { + return this.error.status + } + + hasErrorWithCode(code: String): boolean { + return this.githubErrors.some((err) => err.code == code) } toString(): string { - 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() - } - } - - private customErrorMessage(): string { - const message = this.error.message; - const documentation = this.error.documentation_url - - let documentationMessage: string - if (documentation) { - documentationMessage = `\nPlease see ${documentation}.` + const message = this.error.message + const errors = this.githubErrors + const status = this.status + if (errors.length > 0) { + return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}` } else { - documentationMessage = "" + return `Error ${status}: ${message}` } - - return `${message}${documentationMessage}` } - private invalidFieldMessage(): string { - const resource = this.error.resource - const field = this.error.field - - return `The ${field} field on ${resource} is an invalid format.` - } - - private missingResourceMessage(): string { - const resource = this.error.resource - return `${resource} does not exist.` - } - - private missingFieldMessage(): string { - const resource = this.error.resource - const field = this.error.field - - return `The ${field} field on ${resource} is missing.` - } - - private resourceAlreadyExists(): string { - const resource = this.error.resource - return `${resource} already exists.` + private errorBulletedList(errors: GithubErrorDetail[]): string { + return errors.map((err) => `- ${err}`).join("\n") } } + diff --git a/src/GithubErrorDetail.ts b/src/GithubErrorDetail.ts new file mode 100644 index 0000000..50151c9 --- /dev/null +++ b/src/GithubErrorDetail.ts @@ -0,0 +1,65 @@ +export class GithubErrorDetail { + private error: any; + + constructor(error: any) { + this.error = error + } + + get code(): string { + return this.error.code + } + + toString(): string { + 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() + } + } + + private customErrorMessage(): string { + const message = this.error.message; + const documentation = this.error.documentation_url + + let documentationMessage: string + if (documentation) { + documentationMessage = `\nPlease see ${documentation}.` + } else { + documentationMessage = "" + } + + return `${message}${documentationMessage}` + } + + private invalidFieldMessage(): string { + const resource = this.error.resource + const field = this.error.field + + return `The ${field} field on ${resource} is an invalid format.` + } + + private missingResourceMessage(): string { + const resource = this.error.resource + return `${resource} does not exist.` + } + + private missingFieldMessage(): string { + const resource = this.error.resource + const field = this.error.field + + return `The ${field} field on ${resource} is missing.` + } + + private resourceAlreadyExists(): string { + const resource = this.error.resource + return `${resource} already exists.` + } +} diff --git a/src/Main.ts b/src/Main.ts index f4123ac..899dc1d 100644 --- a/src/Main.ts +++ b/src/Main.ts @@ -5,15 +5,15 @@ import { GithubReleases } from './Releases'; import { Action } from './Action'; import { GithubArtifactUploader } from './ArtifactUploader'; import { FileArtifactGlobber } from './ArtifactGlobber'; -import { ErrorMessage } from './ErrorMessage'; +import { GithubError } from './GithubError'; async function run() { try { const action = createAction() await action.perform() } catch (error) { - const errorMessage = new ErrorMessage(error) - core.setFailed(errorMessage.toString()); + const githubError = new GithubError(error) + core.setFailed(githubError.toString()); } }