Skip to content

Commit

Permalink
Bump axios to latest, remove extraneous import and change the code ar…
Browse files Browse the repository at this point in the history
…ound error a bit (#52)
  • Loading branch information
StalemateInc authored Jul 10, 2023
1 parent d3fb434 commit 1897c9a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 83 deletions.
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

44 changes: 28 additions & 16 deletions dist/licenses.txt

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

100 changes: 49 additions & 51 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0",
"axios": "^0.27.2"
"axios": "^1.4.0"
},
"devDependencies": {
"@types/jest": "^29.5.3",
Expand Down
8 changes: 4 additions & 4 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class API {

return response.data
} catch (error: unknown) {
return Promise.reject(toMoreDescriptiveError(error))
throw toMoreDescriptiveError(error)
}
}

Expand All @@ -38,7 +38,7 @@ export class API {

return response.data
} catch (error: unknown) {
return Promise.reject(toMoreDescriptiveError(error))
throw toMoreDescriptiveError(error)
}
}

Expand All @@ -61,7 +61,7 @@ export class API {

return response.data
} catch (error: unknown) {
return Promise.reject(toMoreDescriptiveError(error))
throw toMoreDescriptiveError(error)
}
}

Expand All @@ -74,7 +74,7 @@ export class API {

return response.data
} catch (error: unknown) {
return Promise.reject(toMoreDescriptiveError(error))
throw toMoreDescriptiveError(error)
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ async function run(): Promise<void> {
info(DebugMessages.TICKET_ADDED_TO_VERSION(ticket, version.id))
}
}
} catch (_e) {
const e: Error = _e as Error
setFailed(e)
} catch (e: unknown) {
if (e instanceof Error) {
setFailed(e.message)
} else {
setFailed(String(e))
}
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { debug } from '@actions/core'
import axios, { AxiosError } from 'axios'
import { isAxiosError } from 'axios'
import { ErrorResponse } from './types'

const isAxiosError = <ResponseType>(error: unknown): error is AxiosError<ResponseType> => {
return axios.isAxiosError(error)
}

export const toMoreDescriptiveError = (error: unknown): Error | unknown => {
if (
isAxiosError<ErrorResponse>(error) &&
Expand Down

0 comments on commit 1897c9a

Please sign in to comment.