-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Closed
Labels
Description
The require(cond, message); syntax is nice and lets you think clearly about the restrictions you're enforcing because the condition is a positive (it's easier to think 'when this condition is true, do X', versus 'when this condition isn't true, do X').
require( n <= MAX_NFTS_PER_COLLECTION, "ec.TOOMANY" );And custom errors are nice, because it lets you include additional contextual information along-side an error. However to raise custom errors you must invert the condition which can be slightly more annoying to think about.
if(n > MAX_NFTS_PER_COLLECTION) revert ExtendedTooMany(collectionId)I suggest that the second parameter of require be adjusted to either pass a message string or an expression which returns an Error type:
require( n <= MAX_NFTS_PER_COLLECTION, ExtendedTooMany(collectionId) );