Type inference for exception variable, and some syntax and semantic errors related to that