یه کلاس برای مدیریت خطاهات بساز و در catch ها به کلاس ارجاع بده.ودر داخل کلاس exption ها رو مدیریت کن و پیغام یا انجام عملی خاص رو به راحتی قابل پیاده سازی ست.
یه نمونه از کلاس شخصی سازی exception
[Serializable]
public class CustomException : Exception
{
public CustomException()
: base() { }
public CustomException(string message)
: base(message) { }
public CustomException(string format, params object[] args)
: base(string.Format(format, args)) { }
public CustomException(string message, Exception innerException)
: base(message, innerException) { }
public CustomException(string format, Exception innerException, params object[] args)
: base(string.Format(format, args), innerException) { }
protected CustomException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}