fix warnings for unused variable Exception ex