I am trying to log errors that may happened within my application and insert it into oracle database as below, but I am getting error at substring
that says
Index and length must refer to a location within the string.
catch (Exception EX)
{
string ErrorMsg = EX.Message.Substring(1, 1024);
Error_log(ErrorMsg, null, "InsertProductData", "F0103", null);
MessageBox.Show("Please call technical support", "ُError Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
anyone can help please ? is there more infroamtion I can save too ? anyway to extract error code ? not only the error message ?
Sutloion Feedback
Thank you all .. just want to give feedback for other on how solved issue like this I solved by using below code
string ErrorMsg = ex.Message.Substring(0, Math.Min(ex.Message.Length, 1024));