This project has moved and is read-only. For the latest updates, please go here.
1

Closed

StackOverFlow Exception when dumping exception object

description

  1. Create a console app.
  2. Add the ObjectDumper Nuget
  3. Use this code:
    static void Main(string[] args)
    {
        try
        {
            throw new ApplicationException("app-exception");
        }
        catch (Exception e1)
        {
            try
            {
                throw new ApplicationException("app-exception", e1);
            }
            catch (Exception e2)
            {
                try
                {
                    throw new ApplicationException("app-exception", e2);
                }
                catch (Exception e3)
                {
                    Console.WriteLine(e1.DumpToString("test")); // Causes a StackOverflowException
                }
            }
        }
    
        Console.ReadLine();
    }
Closed Aug 11, 2015 at 8:49 AM by asdandRizzo
Fixed and unit tested

comments

asdandRizzo wrote Oct 7, 2014 at 1:51 PM

I have run next test with TestDriven for VS2010 in .NET 4.0 Client Profile with latest sources as of today and it passed:
 [Test]
        public void DumpToString_innerException()
        {
            try
            {
                throw new ApplicationException("1");
            }
            catch (Exception e1)
            {
                try
                {
                    throw new ApplicationException("2", e1);
                }
                catch (Exception e2)
                {
                    try
                    {
                        throw new ApplicationException("3", e2);
                    }
                    catch (Exception e3)
                    {
                      var result = e1.DumpToString("test");
                      StringAssert.Contains("1",result );
                      StringAssert.Contains("2",result );
                      StringAssert.Contains("3", result );
                    }
                }
            }


        }