-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
CairoSomething isn't workingSomething isn't workingonlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source week
Description
Issue: Inconsistent Error Handling and Missing Error Messages
Problem: The contract lacks proper error handling and meaningful error messages:
- No custom error definitions in the main contract
- Functions can panic with generic Cairo errors
- No validation for invalid input parameters (e.g., negative damage amounts)
- Missing error handling for edge cases
Location: contract/src/systems/game.cairo:1-139
Problematic code:
fn take_damage(ref self: ContractState, amount: u32) {
// No validation for amount > 0
// No validation for amount overflow
PlayerTrait::take_damage(ref player, amount.try_into().unwrap()); // Can panic
}
Impact:
- Poor debugging experience
- Unclear error messages for users
- Potential panic conditions not handled
- Difficult to maintain and troubleshoot
Suggested solution:
- Add error module with custom error constants
- Implement input validation for all functions
- Replace
unwrap()
with proper error handling - Add meaningful error messages for all failure cases
Metadata
Metadata
Assignees
Labels
CairoSomething isn't workingSomething isn't workingonlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source week