Cleaned up exception handling for TypeEncoder exceptions.