Simplify the BadHexChar exception

Use comment and remove the invalidSymbol tag. Also use asserts.
This commit is contained in:
Alex Beregszaszi 2019-11-20 21:35:25 +00:00
parent fc10fc3073
commit dc351ae5fa
2 changed files with 3 additions and 4 deletions

View File

@ -86,7 +86,7 @@ int dev::fromHex(char _i, WhenError _throw)
if (_i >= 'A' && _i <= 'F')
return _i - 'A' + 10;
if (_throw == WhenError::Throw)
BOOST_THROW_EXCEPTION(BadHexCharacter() << errinfo_invalidSymbol(_i));
assertThrow(false, BadHexCharacter, to_string(_i));
else
return -1;
}
@ -103,7 +103,7 @@ bytes dev::fromHex(std::string const& _s, WhenError _throw)
if (h != -1)
ret.push_back(h);
else if (_throw == WhenError::Throw)
BOOST_THROW_EXCEPTION(BadHexCharacter());
assertThrow(false, BadHexCharacter, "");
else
return bytes();
}
@ -114,7 +114,7 @@ bytes dev::fromHex(std::string const& _s, WhenError _throw)
if (h != -1 && l != -1)
ret.push_back((uint8_t)(h * 16 + l));
else if (_throw == WhenError::Throw)
BOOST_THROW_EXCEPTION(BadHexCharacter());
assertThrow(false, BadHexCharacter, "");
else
return bytes();
}

View File

@ -51,7 +51,6 @@ DEV_SIMPLE_EXCEPTION(FileError);
DEV_SIMPLE_EXCEPTION(DataTooLong);
// error information to be added to exceptions
using errinfo_invalidSymbol = boost::error_info<struct tag_invalidSymbol, char>;
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
}