Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,520 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.