top
User Name
Pass Word:

home
archives
features
links
users
faqs
registration!
Blatherings

son of a...
Previous | Next by ben 15 May, 2007 - 12:04 AM

that's just... argh... just... nested deep in the code was this... a small method that throws exceptions around like candy... instead of returning nothing if it doesn't find anything, it blows up... argh

        protected XmlNode GetDomChildAt(NodeType type, string URI, string name, int index)
        {
            if (type == NodeType.Attribute)
            {
                if (index > 0)
                    throw new Exception("Index out of range");
                foreach (XmlAttribute a in domNode.Attributes)
                    if (a.NamespaceURI == URI && a.LocalName == name)
                        return a;
                throw new Exception("Not found");
            }
            else
            {
                int count = 0;
                foreach (XmlNode n in domNode.ChildNodes)
                    if (DomElementNameEquals(n, URI, name))
                        if (count++ == index)
                            return n;
                if (count > 0)
                    throw new Exception("Index out of range");
                else
                    throw new Exception("Not found");
            }
        }




5/15/2007 >> ben

ahh, well, i just found a non-documented method that preempts this... yay for intellisense in visual studio, hehe


5/15/2007 >> AnarchyX

My thoughts exactly. If any of the tards at my shop wrote crap like that, why i'd.... oh wait.. Fuck.. never mind... (sniff sniff, whimper)




You must be logged in to comment.

comments

links

www.flickr.com
This is a Flickr badge showing public photos from Kheiligh. Make your own badge here.

flickr