Skip to content

Commit

Permalink
refactor: replace $e->getMessage() with $e in log_message()
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jun 25, 2022
1 parent 9a29cbc commit 64fa01f
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/CLI/GeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
2 changes: 1 addition & 1 deletion system/Cache/CacheFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion system/Cache/Handlers/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion system/Cookie/CookieStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions system/Database/BaseConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MySQLi/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion system/Database/OCI8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion system/Email/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion system/HTTP/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 64fa01f

Please sign in to comment.