Print the error message returned from the SQL query
Try to follow below code..

   try {
        $query = db_select('node', 'n');
        $query-&gt;fields('n', array('nid'));
        $nid = $query-&gt;execute()-&gt;fetchField();
        drupal_set_message(t('Print your sucess message here'));
      }
    catch(Exception $e){
        drupal_set_message(t('Print your error message here'),'error');
    }