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

fix: Porting throwError function for proper error handling of parseUrl #52

Merged

Conversation

yoshwata
Copy link
Contributor

@yoshwata yoshwata commented Mar 7, 2022

Context

Port the throwError function from scm-github so that the error handling of parseUrl can be done normally.
https://github.com/screwdriver-cd/scm-github/blob/e554b40619b8530d0eadc9ac02f35e3826900ff0/index.js#L57

Objective

Error handling of parseUrl is successful

References

screwdriver-cd/screwdriver#2674

License

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

index.js Outdated
@@ -346,6 +359,16 @@ class GitlabScm extends Scm {
token
})
.then(response => {
if (response.statusCode === 404) {
throwError(`Cannot find repository ${checkoutUrl}`, response.statusCode);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the statusCode is 404, error object is thrown with statusCode as result of runCommand, so no need to add this line.

index.js Outdated
`STATUS CODE ${response.statusCode}: ${JSON.stringify(response.body)}`,
response.statusCode
);
}
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 might be a situation that should not be error on 2xx, so I remove this block.

@y-oksaku
Copy link
Contributor

y-oksaku commented Mar 7, 2022

Could you test that the error has 400 statusCode here?

error => {
assert.match(error.message, expectedError);
}

@yoshwata
Copy link
Contributor Author

yoshwata commented Mar 7, 2022

Could you test that the error has 400 statusCode here?

Thank you. I added a test.

@tkyi tkyi merged commit ea40032 into screwdriver-cd:master Mar 7, 2022
@sd-buildbot
Copy link

🎉 This PR is included in version 2.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yoshwata yoshwata deleted the throws-status-on-parseurl branch March 7, 2022 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants