Add better error handling support.
kazzkiq opened this issue · 1 comments
kazzkiq commented
For now, all I could find about handling errors when a query is executed is this piece from documentation:
When Sparrow encounters an error while executing a query, it will raise an exception with the database error message.
However, I think that maybe a more manageable approach would be interesting. Example:
$query = $db->from('user')->select()->many();
if($query->success) { // return true or false
return $query;
} else {
return $query->listErrors(); // array with errors
}
Some solution like the above would help make easier verifications over the query status.
mikecao commented
I think exceptions are the standard way to deal with errors. You can use a try-catch block and handle it however you want. The error being returned is a fatal error directly from the database so there would never be more than one.