2 Replies - 407 Views - Last Post: 28 April 2017 - 12:01 AM

#1 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 4128
  • View blog
  • Posts: 13,023
  • Joined: 08-June 10

Should (Symfony) Event Listeners throw Exceptions?

Posted 27 April 2017 - 08:03 AM

Hello,

should Event Listeners (from Symfony or any other Framework) throw Exceptions when they encounter a critical failure or would it suffice to stop the event's propagation? I'm not sure what the best way of action is and I haven't found a clue in the Symfony docs either.
Is This A Good Question/Topic? 0
  • +

Replies To: Should (Symfony) Event Listeners throw Exceptions?

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1789
  • View blog
  • Posts: 5,702
  • Joined: 15-January 14

Re: Should (Symfony) Event Listeners throw Exceptions?

Posted 27 April 2017 - 11:40 AM

I guess it would depend on how critical the failure is. If it's a problem for the application to proceed in an unstable state or with Shady Data ™ then you'll probably want to bail out.
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 4128
  • View blog
  • Posts: 13,023
  • Joined: 08-June 10

Re: Should (Symfony) Event Listeners throw Exceptions?

Posted 28 April 2017 - 12:01 AM

View PostArtificialSoldier, on 27 April 2017 - 08:40 PM, said:

If it's a problem for the application to proceed in an unstable state or with Shady Data ™ then you'll probably want to bail out.

That is also possible without throwing exceptions (=> stop propagation), although an exception does carry a lot more information than an aborted event.

But you are certainly right about it depending on the criticality.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1