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: handle errors in closures [1.x] #16

Merged
merged 6 commits into from
Nov 9, 2024
Merged

Conversation

jaulz
Copy link
Contributor

@jaulz jaulz commented Jun 18, 2024

When you pass a closure instead of a class there is obviously no failed method which can be called in case of a failure. This PR adds a simple check and let's the exception bubble up.

I raised the PR to 1.x (because that's what I use with Tenancy package) but can of course adapt the changes to 2.x as well if you want.

@jaulz jaulz changed the title fix: pass parameters to method fix: pass parameters to method [1.x] Jun 18, 2024
@stancl
Copy link
Member

stancl commented Jun 22, 2024

Could you add some tests?

@jaulz
Copy link
Contributor Author

jaulz commented Oct 30, 2024

@stancl sorry for the delay but finally I could manage to work on it 😊

@jaulz
Copy link
Contributor Author

jaulz commented Oct 31, 2024

@stancl okay, I noticed that the proposed change is maybe just too much. Instead I could simply rely on a closure but the issue right now is that errors are not handled properly. My recent changes should fix it with minimal invasion. Could you please have another look?

@jaulz jaulz changed the title fix: pass parameters to method [1.x] fix: handle errors in closures [1.x] Oct 31, 2024
@stancl
Copy link
Member

stancl commented Nov 1, 2024

Can you update the PR desc?

@jaulz
Copy link
Contributor Author

jaulz commented Nov 4, 2024

@stancl sorry, done 😊

@stancl
Copy link
Member

stancl commented Nov 4, 2024

Bit confused about what exactly the test is doing. The entire try-catch is inside the closure?

@jaulz
Copy link
Contributor Author

jaulz commented Nov 5, 2024

Oh, wow, you were right... seems I was very tired and too happy that the test executed at all 😁 I hope it's now working better.

@stancl
Copy link
Member

stancl commented Nov 7, 2024

The diff looks good now. I've confirmed the added test fails without the change. Can you open an additional PR for the 2.x branch? I'd merge them at once.

@stancl stancl merged commit 5946769 into archtechx:1.x Nov 9, 2024
4 checks passed
@jaulz jaulz deleted the patch-3 branch December 9, 2024 08:42
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