Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Inheritance Custom Exceptions

Validation Fails

Trying to validate/pass the exercise for this quiz consistently fails when attempted from Windows or Android. Is my code so wrong it's breaking it or is there a bug?

TooBigException.cs
namespace Treehouse.CodeChallenges
{
    class TooBigException : System.Exception
    {
           TooBigException(string message) : base(message)
           {

           }
    }
}

1 Answer

andren
andren
28,558 Points

A bit of both. There is an issue with your code which is causing the crash, but normally the challenge checker is not meant to crash just because of an issue with the code it's testing, so that part is a bug.

The issue is that you have forgotten to declare the constructor as public. If you don't declare an access modifier then by default C# will assign an access level of private. A private constructor is generally not very useful since the main purpose of a constructor is to be called from other classes.

If you add the public keyword like this:

namespace Treehouse.CodeChallenges
{
    class TooBigException : System.Exception
    {
           public TooBigException(string message) : base(message)
           {

           }
    }
}

Then your code should work.

Thanks Andren. That makes a lot of sense.