fix exception catch order
Merge pull request #594 from kmaehashi/fix-catch-order

Fix exception catch order to improve portability