Raise an exception where $res returns false

$res = $db->select() should always return a resource, but on some occasions false is returned (see #99).

Throw an exception to output information needed to analysis the situation.