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

Also use try/catch in Controller::API::V1::Comment #6262

Closed
wants to merge 1 commit into from

Conversation

okurz
Copy link
Member

@okurz okurz commented Mar 6, 2025

The txn_guard needs an explicit undef in catch

Related progress issue: https://progress.opensuse.org/issues/176862

The txn_guard needs an explicit undef in catch

Related progress issue: https://progress.opensuse.org/issues/176862
Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

Not really an improvement.

Comment on lines +142 to +146
try { $comment->handle_special_contents($self) }
catch ($e) {
undef $txn_guard;
return $self->render(json => {error => $e}, status => 400);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
try { $comment->handle_special_contents($self) }
catch ($e) {
undef $txn_guard;
return $self->render(json => {error => $e}, status => 400);
}
eval { $comment->handle_special_contents($self) }; # using eval as the txn guard interacts badly with try-catch
return $self->render(json => {error => $@}, status => 400) if $@;

Copy link
Member Author

Choose a reason for hiding this comment

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

The advantage would be that we can filter for $@ usage, only leaving eval where we are not using the error message.

Let me demonstrate that in

how do you like that?

Copy link
Contributor

Choose a reason for hiding this comment

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

The case where we need to undefine the txn guard is still worse.

I also don't see it as necessity to enforce use of try-catch and thus filtering doesn't seem very useful. As long as we don't use Try::Tiny anymore which has counter-intuitive behavior for everyone coming from different programming languages we're good.

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.01%. Comparing base (29123e3) to head (df72dae).
Report is 85 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6262   +/-   ##
=======================================
  Coverage   99.01%   99.01%           
=======================================
  Files         398      398           
  Lines       40014    40020    +6     
=======================================
+ Hits        39620    39626    +6     
  Misses        394      394           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@perlpunk perlpunk left a comment

Choose a reason for hiding this comment

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

The advantage would be that we can filter for $@ usage, only leaving eval where we are not using the error message.

Copy link
Contributor

mergify bot commented Mar 21, 2025

This pull request is now in conflicts. Could you fix it? 🙏

@okurz
Copy link
Member Author

okurz commented Mar 21, 2025

included with #6303

@okurz okurz closed this Mar 21, 2025
@okurz okurz deleted the feature/try_comment branch March 21, 2025 14:18
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.

3 participants