Skip to content

Commit 74f12ec

Browse files
authored
Merge pull request #6182 from kenjis/fix-exception-logging
refactor: replace $e->getMessage() with $e in log_message()
2 parents 8a70700 + 7091fd4 commit 74f12ec

12 files changed

Lines changed: 13 additions & 13 deletions

File tree

system/CLI/CLI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ public static function generateDimensions()
673673
// Then let the developer know of the error.
674674
static::$height = null;
675675
static::$width = null;
676-
log_message('error', $e->getMessage());
676+
log_message('error', (string) $e);
677677
}
678678
}
679679

system/CLI/GeneratorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected function renderTemplate(array $data = []): string
234234
try {
235235
return view(config('Generators')->views[$this->name], $data, ['debug' => false]);
236236
} catch (Throwable $e) {
237-
log_message('error', $e->getMessage());
237+
log_message('error', (string) $e);
238238

239239
return view("CodeIgniter\\Commands\\Generators\\Views\\{$this->template}", $data, ['debug' => false]);
240240
}

system/Cache/CacheFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function getHandler(Cache $config, ?string $handler = null, ?strin
7373
try {
7474
$adapter->initialize();
7575
} catch (CriticalError $e) {
76-
log_message('critical', $e->getMessage() . ' Resorting to using ' . $backup . ' handler.');
76+
log_message('critical', $e . ' Resorting to using ' . $backup . ' handler.');
7777

7878
// get the next best cache handler (or dummy if the $backup also fails)
7979
$adapter = self::getHandler($config, $backup, 'dummy');

system/Cache/Handlers/FileHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function save(string $key, $value, int $ttl = 60)
102102

103103
// @codeCoverageIgnoreStart
104104
} catch (Throwable $e) {
105-
log_message('debug', 'Failed to set mode on cache file: ' . $e->getMessage());
105+
log_message('debug', 'Failed to set mode on cache file: ' . $e);
106106
// @codeCoverageIgnoreEnd
107107
}
108108

system/Cookie/CookieStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function fromCookieHeaders(array $headers, bool $raw = false)
4949
try {
5050
return Cookie::fromHeaderString($header, $raw);
5151
} catch (CookieException $e) {
52-
log_message('error', $e->getMessage());
52+
log_message('error', (string) $e);
5353

5454
return false;
5555
}

system/Database/BaseConnection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function initialize()
380380
$this->connID = $this->connect($this->pConnect);
381381
} catch (Throwable $e) {
382382
$connectionErrors[] = sprintf('Main connection [%s]: %s', $this->DBDriver, $e->getMessage());
383-
log_message('error', 'Error connecting to the database: ' . $e->getMessage());
383+
log_message('error', 'Error connecting to the database: ' . $e);
384384
}
385385

386386
// No connection resource? Check if there is a failover else throw an error
@@ -401,7 +401,7 @@ public function initialize()
401401
$this->connID = $this->connect($this->pConnect);
402402
} catch (Throwable $e) {
403403
$connectionErrors[] = sprintf('Failover #%d [%s]: %s', ++$index, $this->DBDriver, $e->getMessage());
404-
log_message('error', 'Error connecting to the database: ' . $e->getMessage());
404+
log_message('error', 'Error connecting to the database: ' . $e);
405405
}
406406

407407
// If a connection is made break the foreach loop

system/Database/MySQLi/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ protected function execute(string $sql)
291291
try {
292292
return $this->connID->query($this->prepQuery($sql), $this->resultMode);
293293
} catch (mysqli_sql_exception $e) {
294-
log_message('error', $e->getMessage());
294+
log_message('error', (string) $e);
295295

296296
if ($this->DBDebug) {
297297
throw $e;

system/Database/OCI8/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ protected function execute(string $sql)
204204

205205
return $result;
206206
} catch (ErrorException $e) {
207-
log_message('error', $e->getMessage());
207+
log_message('error', (string) $e);
208208

209209
if ($this->DBDebug) {
210210
throw $e;

system/Database/Postgre/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function execute(string $sql)
134134
try {
135135
return pg_query($this->connID, $sql);
136136
} catch (ErrorException $e) {
137-
log_message('error', $e);
137+
log_message('error', (string) $e);
138138
if ($this->DBDebug) {
139139
throw $e;
140140
}

system/Database/SQLite3/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function execute(string $sql)
129129
? $this->connID->exec($sql)
130130
: $this->connID->query($sql);
131131
} catch (ErrorException $e) {
132-
log_message('error', $e);
132+
log_message('error', (string) $e);
133133
if ($this->DBDebug) {
134134
throw $e;
135135
}

0 commit comments

Comments
 (0)