• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

letsdrink / ouzo / 24999313747

27 Apr 2026 01:56PM UTC coverage: 84.665% (-1.2%) from 85.822%
24999313747

Pull #334

github

bbankowski
Fix code coverage generation in CI

- Install pcov driver for PostgreSQL job (coverage runs once, not 3x)
- Add --coverage-clover flag to PHPUnit when coverage is enabled
- Skip coverage driver installation for MySQL/SQLite jobs (faster)
- Remove redundant 'test' argument (phpunit.xml has testsuites)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pull Request #334: Migrate to PHP 8.4 (Ouzo 4.0.0)

34 of 43 new or added lines in 10 files covered. (79.07%)

77 existing lines in 11 files now uncovered.

4947 of 5843 relevant lines covered (84.67%)

34.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

46.88
/src/Ouzo/Core/ExceptionHandling/ExceptionHandler.php
1
<?php
2
/*
3
 * Copyright (c) Ouzo contributors, https://github.com/letsdrink/ouzo
4
 * This file is made available under the MIT License (view the LICENSE file for more information).
5
 */
6

7
namespace Ouzo\ExceptionHandling;
8

9
use Exception;
10
use Ouzo\Config;
11
use Ouzo\Routing\RouterException;
12
use Ouzo\UserException;
13

14
class ExceptionHandler
15
{
16
    private bool $errorHandled = false;
17
    private bool $isCli;
18
    private Renderer $errorRenderer;
19

20
    public function __construct(?Renderer $errorRenderer = null)
21
    {
UNCOV
22
        global $argv;
×
23
        $this->isCli = isset($argv[0]);
5✔
24
        $this->errorRenderer = is_null($errorRenderer) ? ($this->isCli ? new CliErrorRenderer() : new ErrorRenderer()) : $errorRenderer;
5✔
25
    }
26

27
    public function handleException($exception): void
28
    {
29
        if (!$this->runOuzoExceptionHandler($exception)) {
2✔
30
            $this->runDefaultHandler($exception);
1✔
31
        }
32
    }
33

34
    protected function runOuzoExceptionHandler($exception): bool
35
    {
36
        if ($exception instanceof UserException) {
2✔
37
            $this->renderUserError(OuzoExceptionData::forException(500, $exception));
×
38
            return true;
×
39
        }
40
        if ($exception instanceof RouterException) {
2✔
41
            $this->handleError(OuzoExceptionData::forException(404, $exception));
1✔
42
            return true;
1✔
43
        }
44
        if ($exception instanceof OuzoException) {
1✔
45
            $this->handleError($exception->asExceptionData());
×
46
            return true;
×
47
        }
48
        return false;
1✔
49
    }
50

51
    protected function runDefaultHandler($exception): void
52
    {
53
        $this->handleError(OuzoExceptionData::forException(500, $exception));
1✔
54
    }
55

56
    public function handleExceptionData(OuzoExceptionData $exceptionData): void
57
    {
58
        $this->handleError($exceptionData);
×
59
    }
60

61
    public function lastErrorHandled(): bool
62
    {
63
        return $this->errorHandled;
×
64
    }
65

66
    protected function handleError($exception): void
67
    {
68
        $this->renderError($exception);
2✔
69
    }
70

71
    private function renderUserError($exception): void
72
    {
73
        if (!$this->isCli) {
×
74
            header('Contains-Error-Message: User');
×
75
        }
76
        $this->renderError($exception, 'user_exception');
×
77
    }
78

79
    protected function renderError(OuzoExceptionData $exceptionData, $viewName = 'exception'): void
80
    {
81
        try {
82
            ExceptionLogger::newInstance($exceptionData)->log();
2✔
83
            $this->errorRenderer->render($exceptionData, $viewName);
2✔
84
            $this->errorHandled = true;
2✔
85
        } catch (Exception $e) {
×
86
            echo "Framework critical error. Exception thrown in exception handler.<br>\n";
×
87
            ExceptionLogger::forException($e)->log();
×
88
            if (Config::getValue('debug')) {
×
89
                echo "<hr>\n";
×
90
                echo "Message: " . $e->getMessage() . "<br>\n";
×
91
                echo "Trace: " . $e->getTraceAsString() . "<br>\n";
×
92
            }
93
        }
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc