add log for query error in database routes