Add context manager for converting exceptions

Change-Id: I7a2766b1121d0c376542aed19592d33f26485290