System.Exception.Exception.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
		public override string ToString ()
		{
			System.Text.StringBuilder result = new System.Text.StringBuilder (ClassName);
			result.Append (": ").Append (Message);

			if (null != _remoteStackTraceString)
				result.Append (_remoteStackTraceString);
				
			if (inner_exception != null) 
			{
				result.Append (" ---> ").Append (inner_exception.ToString ());
				result.Append (Environment.NewLine);
				result.Append (Locale.GetText ("  --- End of inner exception stack trace ---"));
			}

			if (StackTrace != null)
				result.Append (Environment.NewLine).Append (StackTrace);
			return result.ToString();
		}

Usage Example

Example #1
0
        private Exception LogAndConvertJavaException(Exception e)
        {
            Kp2aLog.Log(e.Message);

            if (e is UserInteractionRequiredException)
                return e;
            //seems like UserInteractionRequiredException is not propagated correctly into the C# world, we can't catch it
            // -> rethrow correctly here
            // Note: the Contains-check looks a bit broad, but it should be safe
            if (e.ToString().Contains("keepass2android.javafilestorage.UserInteractionRequiredException"))
            {
                throw new UserInteractionRequiredException();
            }

            Java.Lang.Exception exception = e as Java.Lang.Exception;
            if (exception != null)
            {
                var ex = new Exception(exception.LocalizedMessage ??
                    e.Message ??
                    _app.GetResourceString(UiStringKey.ErrorOcurred) + exception.GetType().Name, e);
                return ex;
            }

            return e;
        }
All Usage Examples Of System.Exception.Exception::ToString