Mike Jonson

Mike Jonson

  • NA
  • 239
  • 190.6k

How call customer exeption

Jul 26 2011 4:17 AM
I chave create my exeption class, but when i call my exeption, show  box with this exeption and program stop.

using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialiazation;

namespace MyToolBar
{

  public class MyXmlExeption : Exception
  {
  public MyXmlExeption() : base() { }
  public MyXmlExeption(string message) : base(message) { }
  public MyXmlExeption(string message, Exception e) : base(message, e) { }
 
  }
}


and here i check, when i will call my exeption

foreach (XmlAttribute atr in ch.Attributes)
  {
 
  if (atr.Name == "img" && atr.Value == "")
  throw new MyXmlExeption("Picture not found in xml file");

  if (atr.Name == "id")
  button1.Name = atr.Value;
  if (atr.Name == "img")
  {
  button1.BackgroundImage = Image.FromFile(atr.Value);
  }
  if (atr.Name == "text")
  button1.Text = atr.Value;
  }


and here i call my exeption

thrd = new Thread(new ParameterizedThreadStart(toolBar1.XmlLoad));
  try
  {
  //?????? ?????? ? ???????????
  thrd.Start(xmlPath);
  }
  catch (MyXmlExeption ex) {  }







Answers (15)