laracasts / Commander

Easily leverage commands and domain events in your Laravel projects.
https://laracasts.com/series/commands-and-domain-events
MIT License
279 stars 68 forks source link

Catch and re-throw exception on command execution #10

Closed Gufran closed 10 years ago

Gufran commented 10 years ago

If a command throws an exception on execution the exception should be handled and bubbled up properly.

GrahamCampbell commented 10 years ago

What is the point in this? We're not modifying the exception in anyway?

Gufran commented 10 years ago

Point is to bubble the exception up so that developers can consume it as required. This PR came from here

https://laracasts.com/forum/?p=2251-exceptions-get-sent-straight-to-browser-catches-ignored/

laracasts commented 10 years ago

I must be missing something.

With the current code (before your PR), why can't developers consume exceptions? A try-catch in the controller or global.php works just fine.

webbear1000 commented 10 years ago

It works great in global.php but a try catch in the controller never got caught. The exception is thrown in the validator not the handler

devonzara commented 10 years ago

I'm able to throw exceptions in the command handler and catch them in the controller just fine; I'm actually doing this in several cases...

JeffreyWay commented 10 years ago

Yeah - if others can provide more clarity, I can help more. But haven't experienced this myself.

Gufran commented 10 years ago

I'll admit that it was really weird but adding this catch statement worked for a couple people. haven't investigated it more though.

On Tue, Sep 2, 2014 at 1:18 AM, Jeffrey Way notifications@github.com wrote:

Closed #10 https://github.com/laracasts/Commander/pull/10.

Reply to this email directly or view it on GitHub https://github.com/laracasts/Commander/pull/10#event-159752943.