From 246a24b81f4f3316d27a75696d7b8a2a22da5ee3 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 24 Jun 2022 09:14:34 +0900 Subject: [PATCH] refactor: replace $e->getMessage() with $e in log_message() --- system/CLI/CLI.php | 2 +- system/CLI/GeneratorTrait.php | 2 +- system/Cache/CacheFactory.php | 2 +- system/Cache/Handlers/FileHandler.php | 2 +- system/Cookie/CookieStore.php | 2 +- system/Database/BaseConnection.php | 4 ++-- system/Database/MySQLi/Connection.php | 2 +- system/Database/OCI8/Connection.php | 2 +- system/Email/Email.php | 2 +- system/HTTP/ResponseTrait.php | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index d88374e80944..39696e2ed002 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -673,7 +673,7 @@ public static function generateDimensions() // Then let the developer know of the error. static::$height = null; static::$width = null; - log_message('error', $e->getMessage()); + log_message('error', $e); } } diff --git a/system/CLI/GeneratorTrait.php b/system/CLI/GeneratorTrait.php index 51706b477cd4..b4b786e9dbe8 100644 --- a/system/CLI/GeneratorTrait.php +++ b/system/CLI/GeneratorTrait.php @@ -234,7 +234,7 @@ protected function renderTemplate(array $data = []): string try { return view(config('Generators')->views[$this->name], $data, ['debug' => false]); } catch (Throwable $e) { - log_message('error', $e->getMessage()); + log_message('error', $e); return view("CodeIgniter\\Commands\\Generators\\Views\\{$this->template}", $data, ['debug' => false]); } diff --git a/system/Cache/CacheFactory.php b/system/Cache/CacheFactory.php index 875dcd3f7bcd..380491192066 100644 --- a/system/Cache/CacheFactory.php +++ b/system/Cache/CacheFactory.php @@ -73,7 +73,7 @@ public static function getHandler(Cache $config, ?string $handler = null, ?strin try { $adapter->initialize(); } catch (CriticalError $e) { - log_message('critical', $e->getMessage() . ' Resorting to using ' . $backup . ' handler.'); + log_message('critical', $e . ' Resorting to using ' . $backup . ' handler.'); // get the next best cache handler (or dummy if the $backup also fails) $adapter = self::getHandler($config, $backup, 'dummy'); diff --git a/system/Cache/Handlers/FileHandler.php b/system/Cache/Handlers/FileHandler.php index 2517c6a5df11..babb7c037be1 100644 --- a/system/Cache/Handlers/FileHandler.php +++ b/system/Cache/Handlers/FileHandler.php @@ -102,7 +102,7 @@ public function save(string $key, $value, int $ttl = 60) // @codeCoverageIgnoreStart } catch (Throwable $e) { - log_message('debug', 'Failed to set mode on cache file: ' . $e->getMessage()); + log_message('debug', 'Failed to set mode on cache file: ' . $e); // @codeCoverageIgnoreEnd } diff --git a/system/Cookie/CookieStore.php b/system/Cookie/CookieStore.php index af7dd2f0e437..40990b6b5005 100644 --- a/system/Cookie/CookieStore.php +++ b/system/Cookie/CookieStore.php @@ -49,7 +49,7 @@ public static function fromCookieHeaders(array $headers, bool $raw = false) try { return Cookie::fromHeaderString($header, $raw); } catch (CookieException $e) { - log_message('error', $e->getMessage()); + log_message('error', $e); return false; } diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index 7ee8b7621c60..50150f324549 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -380,7 +380,7 @@ public function initialize() $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { $connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage()); - log_message('error', 'Error connecting to the database: ' . $e->getMessage()); + log_message('error', 'Error connecting to the database: ' . $e); } // No connection resource? Check if there is a failover else throw an error @@ -401,7 +401,7 @@ public function initialize() $this->connID = $this->connect($this->pConnect); } catch (Throwable $e) { $connectionErrors[] = sprintf('Failover #%d [%s]: %s', ++$index, $this->DBDriver, $e->getMessage()); - log_message('error', 'Error connecting to the database: ' . $e->getMessage()); + log_message('error', 'Error connecting to the database: ' . $e); } // If a connection is made break the foreach loop diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 5badaf1c4881..0e619eba3777 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -291,7 +291,7 @@ protected function execute(string $sql) try { return $this->connID->query($this->prepQuery($sql), $this->resultMode); } catch (mysqli_sql_exception $e) { - log_message('error', $e->getMessage()); + log_message('error', $e); if ($this->DBDebug) { throw $e; diff --git a/system/Database/OCI8/Connection.php b/system/Database/OCI8/Connection.php index dc0b26f57c0e..e4f568f0d00e 100644 --- a/system/Database/OCI8/Connection.php +++ b/system/Database/OCI8/Connection.php @@ -204,7 +204,7 @@ protected function execute(string $sql) return $result; } catch (ErrorException $e) { - log_message('error', $e->getMessage()); + log_message('error', $e); if ($this->DBDebug) { throw $e; diff --git a/system/Email/Email.php b/system/Email/Email.php index 753dfe7d2bf7..9d52b42e4876 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -1654,7 +1654,7 @@ protected function spoolEmail() $success = $this->{$method}(); } catch (ErrorException $e) { $success = false; - log_message('error', 'Email: ' . $method . ' throwed ' . $e->getMessage()); + log_message('error', 'Email: ' . $method . ' throwed ' . $e); } if (! $success) { diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index f8dd174b4332..4175d0594659 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -634,7 +634,7 @@ public function getCookie(?string $name = null, string $prefix = '') return $this->cookieStore->get($name, $prefix); } catch (CookieException $e) { - log_message('error', $e->getMessage()); + log_message('error', $e); return null; }