Skip to content

Conversation

xepozz
Copy link
Member

@xepozz xepozz commented Jul 18, 2024

Q A
Is bugfix?
New feature? ✔️
Breaks BC?
Fixed issues #108

@vjik vjik added the status:under development Someone is working on a pull request. label Jul 22, 2024
@vjik
Copy link
Member

vjik commented Aug 5, 2024

Looks cool! But I suggest do it in separate package.

@xepozz
Copy link
Member Author

xepozz commented Oct 14, 2024

Looks cool! But I suggest do it in separate package.

All the rest implementation, but it's base support for all of them

@xepozz xepozz self-assigned this Oct 14, 2024
@xepozz xepozz changed the title [WIP] Add solution providers Add solution providers Dec 21, 2024
@samdark
Copy link
Member

samdark commented Dec 21, 2024

@xepozz what's missing here?

@xepozz
Copy link
Member Author

xepozz commented Dec 22, 2024

I think I lost some files in the original codebase, some of them already moved to bridge for error handling 😁

@samdark
Copy link
Member

samdark commented Dec 23, 2024

Possible to update it?

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.76%. Comparing base (44f49fa) to head (3a8bcc7).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/Solution/FriendlyExceptionSolution.php 0.00% 4 Missing ⚠️
src/Renderer/HtmlRenderer.php 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #127      +/-   ##
============================================
- Coverage     80.55%   79.76%   -0.80%     
- Complexity      210      213       +3     
============================================
  Files            19       20       +1     
  Lines           679      687       +8     
============================================
+ Hits            547      548       +1     
- Misses          132      139       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@samdark samdark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Need a phpdoc for the interface + README + CHANGELOG. Would you please handle these?

@samdark
Copy link
Member

samdark commented Aug 10, 2025

@xepozz would you please address static analysis issues? https://github.com/yiisoft/error-handler/actions/runs/16853615512/job/47743450768?pr=127

namespace Yiisoft\ErrorHandler\Solution;

/**
* The interface declares an adapter to render a solution for an event.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The interface declares an adapter to render a solution for an event.
* Solution provider finds and renders a solution for a given throwable.


/**
* The interface declares an adapter to render a solution for an event.
* Basically, it renders the error message as-is, but possible could render a button with click-to-fix action that will be handled by an HTTP request (with middleware) back to server.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Basically, it renders the error message as-is, but possible could render a button with click-to-fix action that will be handled by an HTTP request (with middleware) back to server.
* It may render the message as-is, but it could also provide a button with a click-to-fix action that will be handled by an async HTTP request (using a separate middleware).


use Yiisoft\FriendlyException\FriendlyExceptionInterface;

final class FriendlyExceptionSolution implements SolutionProviderInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final class FriendlyExceptionSolution implements SolutionProviderInterface
/**
* Renders a friendly exception.
*/
final class FriendlyExceptionSolution implements SolutionProviderInterface

interface SolutionProviderInterface
{
/**
* Returns true if the implementation may suggest more than regular provider.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Returns true if the implementation may suggest more than regular provider.
* Returns true if solution could be provided for a given throwable.

public function supports(\Throwable $e): bool;

/**
* Generates an HTML code with solution which will be clean by {@see \Yiisoft\ErrorHandler\Renderer\HtmlRenderer} and shown to the end user.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "clean by"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HtmlRenderer has HTML purifier inside, it cleans all the given html tags and attributes except that are in configuration

* The interface declares an adapter to render a solution for an event.
* Basically, it renders the error message as-is, but possible could render a button with click-to-fix action that will be handled by an HTTP request (with middleware) back to server.
*/
interface SolutionProviderInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SolutionProviderInterface must be placed into separate package. yiisoft/error-handler is too heavy dependency for packages, that implement SolutionProviderInterface.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not about any solution in the air. It's about the specific contract between web, user, application and error.
It shouldn't be separated. At least for now.

* The interface declares an adapter to render a solution for an event.
* Basically, it renders the error message as-is, but possible could render a button with click-to-fix action that will be handled by an HTTP request (with middleware) back to server.
*/
interface SolutionProviderInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface should define format of solution. Users of interface should know about format of solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML for sure

@samdark
Copy link
Member

samdark commented Aug 10, 2025

@vjik noted that HTML doesn't suit console handler well. That is true.

@xepozz
Copy link
Member Author

xepozz commented Aug 11, 2025

SolutionProvider's are in use only in the html renderer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:under development Someone is working on a pull request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants