-
-
Notifications
You must be signed in to change notification settings - Fork 17
Add solution providers #127
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
base: master
Are you sure you want to change the base?
Changes from all commits
f09026b
85ec4f0
884f7be
a2574a3
b67993d
a2b5afd
5c2c4b0
7c81988
6e2ceb2
b5e5ddf
dd29662
8bf9840
ce78cfc
5d41ab0
e904abf
6371efe
4d1259a
8cfee00
850326e
a45baf8
ff4a1a0
3a8bcc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,5 @@ composer.lock | |
| /phpunit.phar | ||
| /phpunit.xml | ||
| /.phpunit.cache | ||
| .phpunit.result.cache | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
|
|
||
| /** | ||
| * @var array $params | ||
| */ | ||
|
|
||
| return [ | ||
| 'yiisoft/error-handler' => [ | ||
| 'solutionProviders' => [ | ||
| Yiisoft\Definitions\Reference::to(Yiisoft\ErrorHandler\Solution\FriendlyExceptionSolution::class), | ||
| ], | ||
| ], | ||
| ]; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Yiisoft\ErrorHandler\Solution; | ||
|
|
||
| use Yiisoft\FriendlyException\FriendlyExceptionInterface; | ||
|
|
||
| final class FriendlyExceptionSolution implements SolutionProviderInterface | ||
| { | ||
| public function supports(\Throwable $e): bool | ||
| { | ||
| return $e instanceof FriendlyExceptionInterface && $e->getSolution() !== null; | ||
| } | ||
|
|
||
| public function generate(\Throwable $e): string | ||
| { | ||
| return $e->getSolution(); | ||
|
Check failure on line 18 in src/Solution/FriendlyExceptionSolution.php
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||
| <?php | ||||||
|
|
||||||
| declare(strict_types=1); | ||||||
|
|
||||||
| namespace Yiisoft\ErrorHandler\Solution; | ||||||
|
|
||||||
| /** | ||||||
| * The interface declares an adapter to render a solution for an event. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| interface SolutionProviderInterface | ||||||
xepozz marked this conversation as resolved.
Show resolved
Hide resolved
vjik marked this conversation as resolved.
Show resolved
Hide resolved
xepozz marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HTML for sure |
||||||
| { | ||||||
| /** | ||||||
| * Returns true if the implementation may suggest more than regular provider. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| public function supports(\Throwable $e): bool; | ||||||
xepozz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| /** | ||||||
| * Generates an HTML code with solution which will be clean by {@see \Yiisoft\ErrorHandler\Renderer\HtmlRenderer} and shown to the end user. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by "clean by"?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
| */ | ||||||
| public function generate(\Throwable $e): string; | ||||||
xepozz marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.