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: Simplifying error handling a little bit #2504

Closed

Conversation

langecode
Copy link
Contributor

During work on Bitbucket Server implementation we discovered that skipped pipelines yielded a wrong responses back to the Bitbucket webhook. We tracked this down to the error handling.

I notice that this has actually also been changed on main since we originally forked the project to work on the Bitbucket Server issues. However since the filtering error only ever occur with two different messages I think the solution with creating two constant error instances might be simpler anyway. You can take it or leave it :)

Signed-off-by: Thor Anker Kvisgård Lange <tal@netic.dk>
@woodpecker-bot
Copy link
Collaborator

woodpecker-bot commented Sep 27, 2023

Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-2504.surge.sh

Comment on lines +69 to 71
err := ErrFilteredRestrictions
log.Debug().Str("repo", repo.FullName).Msgf("%v", err)
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can replace here (and below) too the local var err directly with ErrFilteredRestrictions

@qwerty287 qwerty287 added the refactor delete or replace old code label Sep 29, 2023
@qwerty287
Copy link
Contributor

@langecode you also need to format your code: https://ci.woodpecker-ci.org/repos/3780/pipeline/8405/28

@qwerty287
Copy link
Contributor

Except the test you added this is included in #2527

@langecode
Copy link
Contributor Author

langecode commented Oct 5, 2023

Except the test you added this is included in #2527

Yes, I know - we forked the repo prior to #2327 and discovered that the webhook was returning strange http response codes to the git server when pipelines were skipped. That is also why I thought you could take it or leave it - feel free to close the PR if you want. I think I also mentioned in the initial text that it was already fixed in main.

The reason why I chose to propose it anyway is that I think introducing a separate type here, that can ever only hold two different values is somewhat more complex to have two "constants" with the two errors. Had the error struct contained more dynamic information it may have been more relevant - but going through the code it is only ever instantiated with two different constant strings.

@qwerty287
Copy link
Contributor

Test extracted to #2547

@qwerty287 qwerty287 closed this Oct 8, 2023
qwerty287 added a commit that referenced this pull request Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor delete or replace old code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants