M
mlt
In the constructor of a class I run various test to check that the input
data is valid, else I throw an exception:
....
....
MyTest(
int const k
, int const h
, U const & u
, U const & v
, P const & c
)
{
int controlnum = c.size() * c[0].size();
int basisnum = (u() - k) * (v.size() - h);
if(k<= 0 || h<=0)
throw std::invalid_argument("k h must be greater than zero");
if(uknots.size() <= 0)
throw std::invalid_argument("u was empty");
if(vknots.size() <= 0)
throw std::invalid_argument("v was empty");
if(controls.size() <= 0)
throw std::invalid_argument("c was empty");
....
....
}
The first thing that needs to be done is to catch the exceptions so the
error messages gets printed to the user. But how do I make sure the right
message is printed, do I make some sort of exception switch?
data is valid, else I throw an exception:
....
....
MyTest(
int const k
, int const h
, U const & u
, U const & v
, P const & c
)
{
int controlnum = c.size() * c[0].size();
int basisnum = (u() - k) * (v.size() - h);
if(k<= 0 || h<=0)
throw std::invalid_argument("k h must be greater than zero");
if(uknots.size() <= 0)
throw std::invalid_argument("u was empty");
if(vknots.size() <= 0)
throw std::invalid_argument("v was empty");
if(controls.size() <= 0)
throw std::invalid_argument("c was empty");
....
....
}
The first thing that needs to be done is to catch the exceptions so the
error messages gets printed to the user. But how do I make sure the right
message is printed, do I make some sort of exception switch?