-
Notifications
You must be signed in to change notification settings - Fork 344
Use Tracy for error handling #1298
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for selfoss canceled.
|
Once we switch to Tracy, it would show a error 500 screen that would instruct user to set up a debug mode. But when the `Configuration` throws an exception, we have no way to determine the `Configuration->debug` property. Let’s end early with a boot error instead of relying on Tracy catching the exception. Nothing else in the file should throw either.
It offers much nicer error traces and the code is significantly cleaner. This was the last thing we used F3 framework for. Now we are officially fat-free-free. So long and thanks for all the fish.
This already existed in 2.19 but was not documented.
Member
Author
|
Okay, I went over the code again and re-tested it and it appears to work as expected:
Exception throwing patchThe relevant hunk was applied when testing individual endpoint/script: diff --git a/cliupdate.php b/cliupdate.php
index 19bcbaac..795e91f1 100644
--- a/cliupdate.php
+++ b/cliupdate.php
@@ -12,6 +12,7 @@ require __DIR__ . '/src/common.php';
$loader = $container->get(helpers\ContentLoader::class);
$updateVisitor = new class implements UpdateVisitor {
public function started(int $count): void {
+ throw new Exception('CLI error');
}
public function sourceUpdated(): void {
diff --git a/src/controllers/About.php b/src/controllers/About.php
index 0a3847be..3d806faa 100644
--- a/src/controllers/About.php
+++ b/src/controllers/About.php
@@ -24,6 +24,7 @@ final readonly class About {
* json
*/
public function about(): never {
+ throw new \Exception('API error');
$wallabag = !empty($this->configuration->wallabag) ? [
'url' => $this->configuration->wallabag, // string
'version' => $this->configuration->wallabagVersion, // int
diff --git a/src/controllers/Index.php b/src/controllers/Index.php
index 4c862037..1b6d7f81 100644
--- a/src/controllers/Index.php
+++ b/src/controllers/Index.php
@@ -39,6 +39,7 @@ final readonly class Index {
$options = $_GET;
if (!$this->view->isAjax()) {
+ throw new \Exception('HTML error');
$home = BASEDIR . '/public/index.html';
if (!file_exists($home) || ($homeData = file_get_contents($home)) === false) { // For PHPStan: Error will be already handled by global error handler.
http_response_code(500);
@@ -54,6 +55,7 @@ final readonly class Index {
$this->authentication->ensureCanRead();
+ throw new \Exception('AJAX error');
// load tags
$tags = $this->tagsDao->getWithUnread();
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tracy produces much nicer error messages and allows us to get rid of F3.
The version supporting PHP 5.6 unfortunately produces warnings on PHP 8.0. Also until Tracy 2.9 (for PHP 7.3+) starts a session, which conflicts withsession_set_cookie_params.Find out why ajax requests do not appear in tracy panelseems to work with 2.9integrate PDO into tracy panelcan be done later