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

ErrorCatcher renderers do not have access to the response object. #13

Closed
kamarton opened this issue Nov 4, 2019 · 4 comments
Closed

Comments

@kamarton
Copy link

kamarton commented Nov 4, 2019

What steps will reproduce the problem?

yiisoft/yii-web#146 issues would require you to add headers to the response. It is also required for other applications where a change in the cache header is warranted in the response, e.g. if the error is persistent, it may be appropriate to use stale-if-error with a higher value.

What do you get instead?

It is not currently available.

Q A
Version 3.0.x-dev
PHP version -
Operating system -
@samdark
Copy link
Member

samdark commented Nov 4, 2019

I see multiple ways solving it:

  1. We may merge ErrorCatcher and ErrorHandler. But I don't like the solution because ErrorHandler is used also for fatal errors that aren't in the context of PSR-7 request-response.
  2. We may make renderer return headers as well. That would work but we have to rename it somehow since it won't be strictly rendering anymore.

@kamarton
Copy link
Author

kamarton commented Nov 4, 2019

We may make renderer return headers as well. That would work but we have to rename it somehow since it won't be strictly rendering anymore.

I prefer this solution. What you may need:

  • override headers (array list)
  • status code override (int)
    At the moment, I think these are enough.

@samdark
Copy link
Member

samdark commented Nov 4, 2019

Like this?

class ThrowableRenderer
{
    // ...
    public function render(\Throwable $t): RenderedError;
}

class RenderedError
{
    public function getBody(): string;
    public function getHeaders(): array;
    public function getStatusCode(): int;
}

@kamarton
Copy link
Author

kamarton commented Nov 4, 2019

Like this?

yes

@samdark samdark transferred this issue from yiisoft/yii-web Nov 22, 2020
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

No branches or pull requests

2 participants