Skip to content

Commit

Permalink
Reorder GitHub workflow and enhance error messages
Browse files Browse the repository at this point in the history
The order of the GitHub workflow has been adjusted to prioritize code quality check. Furthermore, error handling in Utils.php has been improved to provide more precise error severity descriptions. This enhances troubleshooting by providing more accurate error context.
  • Loading branch information
SmetDenis committed Apr 11, 2024
1 parent 55ecad3 commit 0a4be96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ jobs:
- name: 🧪 PHPUnit Tests
run: make test --no-print-directory

- name: 👍 Code Quality
run: make codestyle --no-print-directory

- name: Uploading coverage to coveralls
continue-on-error: true
env:
Expand All @@ -78,6 +75,9 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: 👍 Code Quality
run: make codestyle --no-print-directory

- name: Upload Artifacts
uses: actions/upload-artifact@v4
continue-on-error: true
Expand Down
10 changes: 8 additions & 2 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,14 @@ public static function init(): void
// Convert all errors to exceptions. Looks like we have critical case, and we need to stop or handle it.
// We have to do it becase tool uses 3rd-party libraries, and we can't trust them.
// So, we need to catch all errors and handle them.
\set_error_handler(static function ($severity, $message, $file, $line): void {
throw new Exception("{$severity}: \"{$message}\" in file \"{$file}:{$line}\"");
\set_error_handler(static function (int $severity, string $message, string $file, int $line): bool {
$severity = match ($severity) {
\E_ERROR, \E_CORE_ERROR, \E_COMPILE_ERROR, \E_USER_ERROR => 'Error',
\E_WARNING, \E_CORE_WARNING, \E_COMPILE_WARNING, \E_USER_WARNING => 'Warning',
\E_NOTICE, \E_USER_NOTICE => 'Notice',
default => 'Unknown',
};
throw new Exception("Unexpected {$severity}: \"{$message}\" in file \"{$file}:{$line}\"");
});
}

Expand Down

0 comments on commit 0a4be96

Please sign in to comment.