Improve error messages from to_addr and to_subnet BIFs

Related to GH-514
This commit is contained in:
Jon Siwek 2019-08-01 10:49:03 -07:00
parent ac7daf8456
commit ec4df80c67
9 changed files with 115 additions and 30 deletions

View file

@ -863,19 +863,10 @@ Val* AddrVal::DoClone(CloneState* state)
SubNetVal::SubNetVal(const char* text) : Val(TYPE_SUBNET)
{
string s(text);
size_t slash_loc = s.find('/');
val.subnet_val = new IPPrefix();
if ( slash_loc == string::npos )
{
if ( ! IPPrefix::ConvertString(text, val.subnet_val) )
reporter->Error("Bad string in SubNetVal ctor: %s", text);
val.subnet_val = new IPPrefix();
}
else
{
val.subnet_val = new IPPrefix(s.substr(0, slash_loc),
atoi(s.substr(slash_loc + 1).c_str()));
}
}
SubNetVal::SubNetVal(const char* text, int width) : Val(TYPE_SUBNET)