I have the following method:
Code Code Code Code Code Code Code Code Code Code Code Code Code Code |
how do i add a custome error message to teh message Property of "ex" and throw the ex object to teh caller from catch block?
TY in Advance
Code Code Code Code Code Code Code Code Code Code Code Code Code Code |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Roei BarRank #1,271 · 1.4K reputationPosted Sep 13, 2009, 9:22 AM EDT
in the catch you will write :
we create a serializable Exception Class:
[Serializable] public class _ErrorException : Exception { public string ErrorMessage { get { return base.Message.ToString(); } } public _ErrorException(string errorMessage) : base(errorMessage) {} public _ErrorException(string errorMessage, Exception innerEx) : base(errorMessage, innerEx) {} }public class MyCustomException : _ErrorException { public InternalErrorException(string errorMessage) : base(errorMessage) {} public InternalErrorException(string errorMessage, Exception innerEx) : base(errorMessage, innerEx) {} }petre ricardo155 reputationPosted Sep 13, 2009, 5:41 PM EDT
1. But why we create a Serializable Exception class
2.
public InternalErrorException(string errorMessage) : base(errorMessage) {} public InternalErrorException(string errorMessage, Exception innerEx) : base(errorMessage, innerEx) {}I'm assuming that "InternalErrorException" that you have tried to meant the constructor of the mYCustomerException class therefore souldn't the name "InternalErrorException" changed to "MyCustomerException"?