mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Simplify the BadHexChar exception
Use comment and remove the invalidSymbol tag. Also use asserts.
This commit is contained in:
parent
fc10fc3073
commit
dc351ae5fa
libdevcore
@ -86,7 +86,7 @@ int dev::fromHex(char _i, WhenError _throw)
|
|||||||
if (_i >= 'A' && _i <= 'F')
|
if (_i >= 'A' && _i <= 'F')
|
||||||
return _i - 'A' + 10;
|
return _i - 'A' + 10;
|
||||||
if (_throw == WhenError::Throw)
|
if (_throw == WhenError::Throw)
|
||||||
BOOST_THROW_EXCEPTION(BadHexCharacter() << errinfo_invalidSymbol(_i));
|
assertThrow(false, BadHexCharacter, to_string(_i));
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ bytes dev::fromHex(std::string const& _s, WhenError _throw)
|
|||||||
if (h != -1)
|
if (h != -1)
|
||||||
ret.push_back(h);
|
ret.push_back(h);
|
||||||
else if (_throw == WhenError::Throw)
|
else if (_throw == WhenError::Throw)
|
||||||
BOOST_THROW_EXCEPTION(BadHexCharacter());
|
assertThrow(false, BadHexCharacter, "");
|
||||||
else
|
else
|
||||||
return bytes();
|
return bytes();
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ bytes dev::fromHex(std::string const& _s, WhenError _throw)
|
|||||||
if (h != -1 && l != -1)
|
if (h != -1 && l != -1)
|
||||||
ret.push_back((uint8_t)(h * 16 + l));
|
ret.push_back((uint8_t)(h * 16 + l));
|
||||||
else if (_throw == WhenError::Throw)
|
else if (_throw == WhenError::Throw)
|
||||||
BOOST_THROW_EXCEPTION(BadHexCharacter());
|
assertThrow(false, BadHexCharacter, "");
|
||||||
else
|
else
|
||||||
return bytes();
|
return bytes();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ DEV_SIMPLE_EXCEPTION(FileError);
|
|||||||
DEV_SIMPLE_EXCEPTION(DataTooLong);
|
DEV_SIMPLE_EXCEPTION(DataTooLong);
|
||||||
|
|
||||||
// error information to be added to exceptions
|
// 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>;
|
using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user