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

feat: improve error logs #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cchanche
Copy link
Contributor

  • Removed obsolete error log (300d187)

I think it is a duplicate from the github-connector.

  • Add log to suggest checking the jira-token when the jira GET request fails with status code 401 (58d17dd)

Solves #33

@cchanche cchanche changed the title Improve error logs feat: improve error logs Jan 18, 2023
Copy link
Owner

@cakeinpanic cakeinpanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, tiny comment!

@@ -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');
Copy link
Owner

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, my mistake

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');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love this!

@@ -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) {
Copy link
Owner

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

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants