Handle errors for rss parser
<p>I have a rss feed reader application. The goal is to store the title and image for each item in a custom object named RSSItem, and oll the RSSItem objects in another object named RSSFeed. The problem is that if an item element does not have an enclosure element SaxException is thrown. How should I handle the errors with this parser? Here is the parser code:</p>

<pre><code>    public class Parser {
 private final String RSS_ELEMENT = "rss";
 private final String CHANNEL_ELEMENT = "channel";
 private final String ITEM_ELEMENT = "item";
 private final String ENCLOSURE_ELEMENT = "enclosure";
 private final String TITLE_ELEMENT = "title";

 private final String URL_ATTRIBUTE = "url";
 private final String TYPE_ATTRIBUTE = "type";

 private final String IMAGE_TYPE = "image/jpeg";

 RSSItem rssItem;
 RSSFeed rssFeed;

 final URL mFeedUrl;

 public Parser(String feedUrl) {
    try {
            mFeedUrl = new URL(feedUrl);
       } catch (MalformedURLException e) {
        Log.e(e.getClass().getSimpleName(), e.getMessage());
           throw new RuntimeException(e);
       }
  rssFeed = new RSSFeed();
 }

 protected InputStream getInputStream() {
  try {
   return mFeedUrl.openConnection().getInputStream();
  } catch (IOException e) {
   Log.e(e.getClass().getSimpleName(), e.getMessage());
   return null;
  }
 }

 public RSSFeed parse() {
  InputStream istream = getInputStream();

  RootElement root = new RootElement(RSS_ELEMENT);
  Element channel = root.requireChild(CHANNEL_ELEMENT);

  Element itemElement = channel.requireChild(ITEM_ELEMENT);
  Element enclosure = itemElement.requireChild(ENCLOSURE_ELEMENT);  
  Element title = itemElement.requireChild(TITLE_ELEMENT);

  enclosure.setStartElementListener(new StartElementListener() {
   public void start(Attributes attrs) {
    String imageType = attrs.getValue(TYPE_ATTRIBUTE);
    if (imageType.equals(IMAGE_TYPE)) {
     try {
      String imageUrl = attrs.getValue(URL_ATTRIBUTE);
      Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(imageUrl).getContent());
      rssItem.setImage(bitmap);
     } catch (MalformedURLException e) {
      e.printStackTrace();
     } catch (IOException e) {
      e.printStackTrace();
     }
    }
   }
  });

  title.setEndTextElementListener(new EndTextElementListener() {
   public void end(String body) {
    rssItem.setTitle(body);
   }
  });

  itemElement.setStartElementListener(new StartElementListener() {
   public void start(Attributes arg0) {
    rssItem = new RSSItem();
   }
  });

  itemElement.setEndElementListener(new EndElementListener() {
   public void end() {
    rssFeed.addItem(rssItem);
   }
  });

  try {
   Xml.parse(istream, Xml.Encoding.UTF_8, root.getContentHandler());
  } catch (Exception e) {
   e.printStackTrace();
  }

  return rssFeed;
 }
}
</code></pre>
