The PHP Handbook
will be executed if there’s an exception in the try block: try { //do something } catch (Throwable $e) { //we can do something here if an exception happens } Notice that we have an Exception object to get more information about the exception, like this: try { //do something } catch (Throwable $e) { echo $e->getMessage(); } Let’s do an example. For example by mistake I divide a number block, the program ends successfully, telling me the problem: try { echo 1 / 0; } catch (Throwable $e) { echo $e->getMessage(); } 62 Of course this is a simple example but you can see the0 码力 | 97 页 | 8.78 MB | 1 年前3
CakePHP Cookbook 4.x
Cake\Error\ErrorLoggerInterface; use Cake\Error\PhpError; use Psr\Http\Message\ServerRequestInterface; use Throwable; /** * Log errors and unhandled exceptions to `Cake\Log\Log` */ class ErrorLogger implements App\Error; use Cake\Error\ErrorLoggerInterface; use Psr\Http\Message\ServerRequestInterface; use Throwable; /** * Log errors and unhandled exceptions to `Cake\Log\Log` */ class ErrorLogger implements $message, array $context = []): bool { // Log PHP Errors } public function log(Throwable $exception, ?ServerRequestInterface $request = null): bool { // Log exceptions.0 码力 | 1249 页 | 1.04 MB | 1 年前3
CakePHP Cookbook 4.x
Cake\Error\ErrorLoggerInterface; use Cake\Error\PhpError; use Psr\Http\Message\ServerRequestInterface; use Throwable; /** * Log errors and unhandled exceptions to `Cake\Log\Log` */ class ErrorLogger implements App\Error; use Cake\Error\ErrorLoggerInterface; use Psr\Http\Message\ServerRequestInterface; use Throwable; /** * Log errors and unhandled exceptions to `Cake\Log\Log` */ class ErrorLogger implements logMessage($level, string $message, array $context = []): bool { // Log PHP Errors } public function log(Throwable $exception, ?ServerRequestInterface $request = null):␣ ˓→bool { // Log exceptions. } } New in0 码力 | 967 页 | 2.88 MB | 1 年前3
CakePHP Cookbook Documentation 5.xCake\Error\ErrorLoggerInterface; use Cake\Error\PhpError; use Psr\Http\Message\ServerRequestInterface; use Throwable; /** * Log errors and unhandled exceptions to `Cake\Log\Log` */ class ErrorLogger implements0 码力 | 1080 页 | 939.39 KB | 1 年前3
CakePHP Cookbook Documentation 5.xCake\Error\ErrorLoggerInterface; use Cake\Error\PhpError; use Psr\Http\Message\ServerRequestInterface; use Throwable; /** * Log errors and unhandled exceptions to `Cake\Log\Log` */ class ErrorLogger implements0 码力 | 848 页 | 2.53 MB | 1 年前3
共 5 条
- 1













