gov.va.medora.mdws.MdwsUtils.isException C# (CSharp) Method

isException() public static method

The TO objects need to determine if an object is derived from an exception. The most reliable way to do this is simply to look at the method name and see if it ends with the text: Exception
public static isException ( object obj ) : bool
obj object The object to check if it is an exception
return bool
        public static bool isException(object obj)
        {
            try
            {
                if (obj == null)
                {
                    return false;
                }
                // TBD: should we really be checking the object's name? seems awfully kludgy. Maybe a better way to check
                // if the object derives from the Exception class?
                if (obj.GetType().Name.EndsWith("Exception"))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }