Replace error strings with custom errors (#4261)

This commit is contained in:
Francisco Giordano
2023-06-06 01:08:31 -03:00
parent 253bfa68c2
commit 99a4cfca17
133 changed files with 3157 additions and 1204 deletions

View File

@ -66,6 +66,11 @@ const defaultMap = () => `\
// 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;
@ -149,7 +154,9 @@ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view retu
*/
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;
}