Since PHP 7 and for WP in particular I would suggest to put your your logical parts to separate files and then load them in try catch, because PHP 7 added the \Throwable which can also catch Error including syntax errors when including file - but only from outside the script being included.
So for example in your functions.php you will do include/require/include_once/require_once and put a logic in yourTheme/your_script_with_syntax_errors.php:
functions.php part will look like:
try {
require_once __DIR__ . '/your_script_with_syntax_errors.php';
} catch (\Throwable $e) {
// bypassed ...
// you can put your error handling/logging here
}
echo "Script continues...";
Which in case of a syntax error in the included script will still result in something like:
...
Script continues...
So as you can see, even though there was a syntax error in the included file, the main script still continues...
If you don't want to use an existing logger, you can implement custom error handler and trigger_error in the catch.
set_error_handler(function (int $errno, string $errstr, string $errfile = ?, int $errline = ?, array $errcontext = ?) {
// log something somewhere...
});
Note that if you don't add an error handler that doesn't print out the message, the error will be output based on your error_reporting level.