-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: improve error logs #37
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import axios, { AxiosInstance } from 'axios'; | ||
import { isAxiosError } from './utils'; | ||
import { getInputs } from './action-inputs'; | ||
import { JIRA, JIRADetails } from './types'; | ||
import { error as coreError, info as coreInfo } from '@actions/core'; | ||
|
||
export class JiraConnector { | ||
client: AxiosInstance; | ||
|
@@ -46,8 +48,9 @@ export class JiraConnector { | |
}, | ||
}; | ||
} catch (error) { | ||
if (error.response) { | ||
throw new Error(JSON.stringify(error.response, null, 4)); | ||
if (isAxiosError(error) && error?.response?.status === 401) { | ||
coreError('Jira request failed, check your jira-token.'); | ||
coreInfo('Does your jira-token include the required prefix ? See https://github.com/cakeinpanic/jira-description-action#jira-token'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. love this! |
||
} | ||
throw error; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ async function run(): Promise<void> { | |
const details = await jiraConnector.getTicketDetails(issueKey); | ||
await githubConnector.updatePrDetails(details); | ||
} catch (error) { | ||
console.log('JIRA key was not found'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please don't remove this output, it's needed for the case when token is ok, just the jira task not exisitng There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, my mistake |
||
core.error(error.message); | ||
|
||
if (FAIL_WHEN_JIRA_ISSUE_NOT_FOUND) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also played with this and could not get a 401, even if I'm having incorrect credentials, I'm getting 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's weird, I am not sure how that used to play out for me though...
Maybe a simple info-log with the error code could do the trick, whatever the type of error