Link to home
Create AccountLog in
Avatar of onebite2
onebite2

asked on

Exception message not being logged

I am logging all the exceptions into a table in database ,inside the code I am using a variable to read the entire message from a function ,but only the value is being saved not the entire message ...how can I change the parseuptomaxlength  function below so that entire message is logged??

For example :
If a function has an exception message like below

Throw New Exception(" A valid value must be provided for year built with value. Value is '" + Row.inYEARBUILT.ToString() + "'")

only the 'Row.inYEARBUILT.ToString() ' value is being logged into the Error description and not the entire message in the following variable ...

Row.ComplexTransformErrorDescription = ParseUpToMaxLength("ULDD - " + ex.Message.Replace(Environment.NewLine, " "), 256)


  Function ParseUpToMaxLength(ByVal value As String, ByVal maxLength As Integer) As String
        If value.Length > maxLength Then
            Return value.Substring(0, maxLength)
        Else
            Return value
        End If
    End Function
Avatar of IrogSinta
IrogSinta
Flag of United States of America image

I'm not seeing anything wrong with your function.  Perhaps the problem lies somewhere else.  Can you post more of the code?
ASKER CERTIFIED SOLUTION
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.