You do not need a member variable to store the message in your own exception class, because the superclass Exception already has such a member variable. Write your own exception class by implementing four constructors, like this:
Those four constructors correspond to the constructors of the base class Exception.
And then use it like this:
Use the standard getMessage() method from class Exception to see the message: