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

Proposal: Throwable responses #2012

Closed
vlakoff opened this issue Oct 11, 2016 · 5 comments
Closed

Proposal: Throwable responses #2012

vlakoff opened this issue Oct 11, 2016 · 5 comments
Labels
discussion pending response Waiting on a response from the original poster Slim 4

Comments

@vlakoff
Copy link
Contributor

vlakoff commented Oct 11, 2016

Would you be interested in a feature like laravel/framework#13473?

Currently, throwing a response requires the following. As more, SlimException isn't really appropriate.

$response = $response->withRedirect($url);
throw new \Slim\Exception\SlimException($request, $response);

Whereas a few additions would allow to do this:

$response->withRedirect($url)->throwResponse();

Note the request isn't used actually.

@geggleto geggleto added discussion pending response Waiting on a response from the original poster Slim 4 labels Mar 14, 2017
@geggleto geggleto modified the milestone: 4.0 Mar 19, 2017
@KuroThing
Copy link

Exceptions as control flow are generally considered an anti pattern, there is some discussion about it on stackoverflow.

@vlakoff
Copy link
Contributor Author

vlakoff commented May 21, 2017

Sure thing, but there are exceptions to this. In this situation, exceptions play really nice.

  • Otherwise you have to propagate returns all the way up, which sometimes isn't even doable.
  • These exceptions allows fine-grained and centralized handling (error handling, logging, and much more).
  • Features like Laravel's terminable middlewares free you from the sequential flow constraint.

As a result, you have a really great application flow that wouldn't be possible without these exceptions.

@KuroThing
Copy link

And exceptions are not not designed for this kind of control flow.

In a website that has thousands of hits an hour, using Exceptions as Control Flow is terrible performance wise, and doesn't scale. At all.

Why encourage bad design?

@geggleto
Copy link
Member

I can't get behind this idea at all.

Throwable response will not work in Slim.

The idea being that you can immediately terminate from the app strikes me as weird as it's you need to go back through your middleware to complete any actions, throwing response breaks that.

@vlakoff
Copy link
Contributor Author

vlakoff commented May 23, 2017

Populus locutus est, closing as there is a clear consensus, no need to pursue.

@vlakoff vlakoff closed this as completed May 23, 2017
@akrabat akrabat removed this from the 4.0 milestone Sep 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion pending response Waiting on a response from the original poster Slim 4
Projects
None yet
Development

No branches or pull requests

4 participants