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

dev/core#560 Update Cancel Billing & update billing to use status bounce rather than fatal #13850

Merged
merged 1 commit into from
Mar 23, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Mar 18, 2019

Overview

Minor stdisation on error handling

Before

Screenshot 2019-03-18 14 06 29

After

Screenshot 2019-03-18 14 24 32

(It's slightly weird that the box starts to open & then closes & the error msg pops up but IMHO it's still better)

Technical Details

Per https://lab.civicrm.org/dev/core/issues/560 we have resolved to get rid of fatal & move
to throwing Exceptions.

However, I'm leaning towards making statusBounces the rules for when we just deem a form inaccessible.

In this case we have 3 parallel forms - cancel, update & a similar update but slightly different just cos.

One does a status bounce - 2 spit out fatals when access not available.

Just looking at Cancel these are the places that still have fatal

  • The recurring contribution looks to have been cancelled already
  • Required information missing

I'm not sure the value of a fatal as opposed to the gentler statusBounces in either of those cases.

Throwing an exception looks very much like a fatal except

  1. it doesn't hurt tests or cli tools as much
  2. IF display backtrace is enabled THEN the back trace displays - ie

Screenshot 2019-03-18 14 06 49

so, it's generally better BUT I kinda feel like the only time when it's actually better than a status
bounce is when a bug has occurred (eg. an unexpectedly failed api call) - anything we anticipate
seems like a bounce to me....

Comments

@colemanw @seamuslee001 @monishdeb @mattwire @jitendrapurohit @pradpnayak @totten
I feel like it would be good to have a generalised agreement on when to use statusBounce as opposed to throwing an exception. Per above I would say almost always at the form layer

…an fatal

Per https://lab.civicrm.org/dev/core/issues/560 we have resolved to get rid of fatal & move
to throwing Exceptions.

However, I'm leaning towards making statusBounces the rules for when we just deem a form inaccessible.

In this case we have 3 paralel forms - cancel, update & a similar update but slightly different just cos.

One does a status bounce - 2 spit out fatals when access not available.

Just looking at Cancel these are the places that still have fatal

- The recurring contribution looks to have been cancelled already
- Required information missing

I'm not sure the value of a fatal as opposed to the gentler statusBounces in either of those cases.

Throwing an exception looks very much like a fatal except
1) it doesn't hurt tests or cli tools as much
2) IF display backtrace is enabled THEN the back trace displays.

so, it's generally better BUT I kinda feel like the only time when it's actually better than a status
bounce is when a bug has occurred (eg. an unexpectedly failed api call) - anything we anticipate
seems like a bounce to me....
@civibot
Copy link

civibot bot commented Mar 18, 2019

(Standard links)

@civibot civibot bot added the master label Mar 18, 2019
@mattwire
Copy link
Contributor

@eileenmcnaughton This looks simple and I agree that switching fatal to statusbounce is almost always the correct thing to do at the form layer. My only concern is that this is making the same change on both forms with identical code that could instead be extracted out into a shared parent class per your comments on #13285. My preferred approach is actually to align the code on each of the forms before extracting the common functionality but I feel we should do one or the other and not both!

@eileenmcnaughton
Copy link
Contributor Author

@mattwire the process of aligning the code feels very risky & error prone to me - lots of renaming variables to the 'wrong' thing in order to make them the 'same' in order to be able to compare them. I feel much more comfortable extracting a function to a trait or shared parent & then cleaning it up & then working through the other forms to ensure they can use the function & keeping each step small (& obviously looking to where we can add tests).

Regarding this PR - I think using it as a discussion piece on when we use statusBounce & when we use Exceptions is probably more important that whether it actually gets merged

@mattwire
Copy link
Contributor

@eileenmcnaughton That makes sense, I'd suggest we do the same with this PR as the two code blocks are identical except for the text in the message.
Re switching to statusbounce I thought we already had consensus that it was the right thing to do eg. https://github.com/civicrm/civicrm-core/pulls?q=is%3Apr+statusbounce+is%3Aclosed

@eileenmcnaughton
Copy link
Contributor Author

@mattwire well issue 560 is about replacing fatal with throwing exceptions - but I'm wondering if that is what we should be doing

@mattwire
Copy link
Contributor

There's a related issue somewhere that came up recently @mfb? because fatal() causes issues with the PEAR error scope and suppresses errors in some cases.

@mfb
Copy link
Contributor

mfb commented Mar 19, 2019

Not sure which specific issue you're referring to, maybe #13682? The push for nicer error notifications in the UI sounds great (as does throwing exceptions, in non-UI code).

@mattwire
Copy link
Contributor

@mfb thanks yes it was #13682

@eileenmcnaughton eileenmcnaughton merged commit f0372b6 into civicrm:master Mar 23, 2019
@eileenmcnaughton eileenmcnaughton deleted the bounce branch March 23, 2019 20:51
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.

3 participants