Skip to content

Commit

Permalink
Improve error messages (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored Oct 11, 2023
1 parent b65fc75 commit e82a3fc
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 33 deletions.
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

0 comments on commit e82a3fc

Please sign in to comment.