DataQuery: properly log exceptions.

Signed-off-by: Claus-Justus Heine <himself@claus-justus-heine.de>
This commit is contained in:
Claus-Justus Heine
2023-08-22 11:09:37 +02:00
parent 338c6b6ffb
commit df5a550fbd

View File

@@ -109,12 +109,12 @@ class DataQuery
}
$query = $this->queryProvider[$queryName];
try {
$result = $this->connection->prepare($query, $limit, $offset);
} catch (DBALException $exception) {
$this->logger->error(
"Could not prepare the query: " . $exception->getMessage(),
["app" => $this->appName]
$this->logger->logException(
$exception, [ 'message' => "Could not prepare the query: " . $query ]
);
return false;
}
@@ -123,19 +123,15 @@ class DataQuery
$result->bindValue(":" . $param, $value);
}
$this->logger->debug(
"Executing query: " . $query . ", " . implode(",", $params),
["app" => $this->appName]
);
$this->logger->debug("Executing query: " . $query . ", " . implode(",", $params));
try {
$result = $result->execute();
return $result;
} catch (DBALException $exception) {
$this->logger->error(
"Could not execute the query: " . $exception->getMessage(),
["app" => $this->appName]
$this->logger->logException(
$exception, [ 'message' => "Could not execute the query: " . $query ]
);
return false;
}