boost::gregorian::date
throws std::out_of_range
type exceptions when day, month or year are out of range.
Your catch block catches exception of int
type. You need to use a catch block with type std::out_of_range
to catch the specific exception.
Also, there is no need to use a throw(20)
statement in your try block.