handle some exception situations.

TODO need to split try catch.