Skip to content

Commit 2481dfc

Browse files
committed
:octocat: DriverInterface: log exceptions
1 parent 620aca7 commit 2481dfc

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/Drivers/DriverAbstract.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ public function raw(string $sql, string $index = null, bool $assoc = null){
161161
return $this->raw_query($sql, $index, $assoc !== null ? $assoc : true);
162162
}
163163
catch(\Exception $e){
164-
throw new DriverException('sql error: ['.get_called_class().'::raw()] '.$e->getMessage());
164+
$msg = 'sql error: ['.get_called_class().'::raw()] '.$e->getMessage();
165+
$this->logger->error($msg);
166+
167+
throw new DriverException($msg);
165168
}
166169

167170
}
@@ -180,7 +183,10 @@ public function prepared(string $sql, array $values = null, string $index = null
180183
);
181184
}
182185
catch(\Exception $e){
183-
throw new DriverException('sql error: ['.get_called_class().'::prepared()] '.$e->getMessage());
186+
$msg = 'sql error: ['.get_called_class().'::prepared()] '.$e->getMessage();
187+
$this->logger->error($msg);
188+
189+
throw new DriverException($msg);
184190
}
185191

186192
}
@@ -200,7 +206,10 @@ public function multi(string $sql, array $values){
200206
return $this->multi_query($sql, $values);
201207
}
202208
catch(\Exception $e){
203-
throw new DriverException('sql error: ['.get_called_class().'::multi()] '.$e->getMessage());
209+
$msg = 'sql error: ['.get_called_class().'::multi()] '.$e->getMessage();
210+
$this->logger->error($msg);
211+
212+
throw new DriverException($msg);
204213
}
205214

206215
}
@@ -225,7 +234,10 @@ public function multiCallback(string $sql, iterable $data, $callback){
225234
return $this->multi_callback_query($sql, $data, $callback);
226235
}
227236
catch(\Exception $e){
228-
throw new DriverException('sql error: ['.get_called_class().'::multiCallback()] '.$e->getMessage());
237+
$msg = 'sql error: ['.get_called_class().'::multiCallback()] '.$e->getMessage();
238+
$this->logger->error($msg);
239+
240+
throw new DriverException($msg);
229241
}
230242

231243
}

0 commit comments

Comments
 (0)