Suppose I would like to make some custom exceptions. And I would like to have more. I can create a new class for each new exception, but is there another way to do this? And if I need to always create a new class, where to store them? Its just not looking so good in the project root folder.
Ahm and another question: what do I do if some exceptions are the same, only the name of the exception changes a little? Assume exception A is as follows:
[Serializable()] public class ExceptionA: Exception, ISerializable { public ExceptionA() : base() { } public ExceptionA(string message) : base(message) { } public ExceptionA(string message, System.Exception inner) : base(message, inner) { } public ExceptionA(SerializationInfo info, StreamingContext context) : base(info, context) { } } }
and the other is one and the same, another name:
[Serializable()] public class ExceptionB: Exception, ISerializable { public ExceptionB() : base() { } public ExceptionB(string message) : base(message) { } public ExceptionB(string message, System.Exception inner) : base(message, inner) { } public ExceptionB(SerializationInfo info, StreamingContext context) : base(info, context) { } } }
And so on. Do I really need to always create a new class and paste the same code? Any suggestions?
silla source share