Hawk High

First Flight #39
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: medium
Invalid

[L-2] Inconsistent Error Handling

Severity

Low

Impact

The contract uses inconsistent error handling patterns, mixing custom errors with require statements and naked reverts, which reduces code quality and readability.

Description

In the expel function, there is a naked revert statement:

if (inSession == false) {
revert();
}

Also, in the giveReview function, string error messages are used instead of custom errors:

require(reviewCount[_student] < 5, "Student review count exceeded!!!");
require(block.timestamp >= lastReviewTime[_student] + reviewTime, "Reviews can only be given once per week");

This inconsistency makes the contract harder to maintain and less gas-efficient, as string error messages consume more gas than custom errors.

Recommended Mitigation

Replace the naked revert with a descriptive custom error:

error HH__SchoolNotInSession();
if (inSession == false) {
revert HH__SchoolNotInSession();
}

Replace require statements with custom errors:

error HH__MaxReviewsExceeded();
error HH__ReviewTooEarly(uint256 nextReviewTime);
if (reviewCount[_student] >= 5) {
revert HH__MaxReviewsExceeded();
}
if (block.timestamp < lastReviewTime[_student] + reviewTime) {
revert HH__ReviewTooEarly(lastReviewTime[_student] + reviewTime);
}

Following a consistent error handling pattern improves code quality, readability, and gas efficiency.

Updates

Lead Judging Commences

yeahchibyke Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.