Fix issues uncovered by static analysis

Use combined catch
Merge pull request #8 from leonyu/fix_issues_uncovered_by_static_analysis

Fix issues uncovered by static analysis