Replace error strings with custom errors (#4261)
This commit is contained in:
@ -57,6 +57,11 @@ library EnumerableMap {
|
||||
// This means that we can only create new EnumerableMaps for types that fit
|
||||
// in bytes32.
|
||||
|
||||
/**
|
||||
* @dev Query for an nonexistent map key.
|
||||
*/
|
||||
error EnumerableMapNonexistentKey(bytes32 key);
|
||||
|
||||
struct Bytes32ToBytes32Map {
|
||||
// Storage of keys
|
||||
EnumerableSet.Bytes32Set _keys;
|
||||
@ -136,7 +141,9 @@ library EnumerableMap {
|
||||
*/
|
||||
function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
|
||||
bytes32 value = map._values[key];
|
||||
require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key");
|
||||
if (value == 0 && !contains(map, key)) {
|
||||
revert EnumerableMapNonexistentKey(key);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user