upgrade exception handling to support custom types in 3rd party libraries