Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages #160

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,23 @@ jobs:
# pytest
# - run: exit 1
# if: success()

# incorrect-version:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: ./
# with:
# micromamba-version: '1.2.3'
# - run: exit 1
# if: success()

# incorrect-log-level:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: ./
# with:
# log-level: foo
# - run: exit 1
# if: success()
70 changes: 56 additions & 14 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 42 additions & 13 deletions dist/post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "tsup",
"dev": "tsup --watch",
"lint": "eslint ./src --ext ts",
"lint:fix": "eslint ./src --ext ts --fix",
"all": "npm run build && npm run lint"
},
"repository": {
Expand Down
15 changes: 14 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'fs/promises'
import { constants as fsConstants } from 'fs' // fs.constants is not available in fs/promises for node < 18.4.0
import os from 'os'
import path from 'path'
import { exit } from 'process'
import * as coreDefault from '@actions/core'
import * as io from '@actions/io'
import { downloadTool } from '@actions/tool-cache'
Expand Down Expand Up @@ -184,4 +185,16 @@ const run = async () => {
await generateInfo()
}

run()
run().catch((error) => {
if (core.isDebug()) {
throw error
}
if (error instanceof Error) {
core.setFailed(error.message)
exit(1)
} else if (typeof error === 'string') {
core.setFailed(error)
exit(1)
}
throw error
})
Loading
Loading