Skip to main content
The NullGraph program defines 6 custom errors to handle validation failures and prevent invalid state transitions. All errors are defined in the NullGraphError enum using Anchor’s #[error_code] macro. Location: lib.rs:579-593

Error Code Enum


InvalidBountyStatus

6000
string
“Bounty is not in the expected status”

Description

Thrown when an instruction attempts to operate on a bounty that is not in the required status.

Thrown By

Status Reference

Code Reference


InvalidSubmissionStatus

6001
string
“Submission is not in the expected status”

Description

Thrown when attempting to approve a submission that is not in Pending status.

Thrown By

Submission Status Reference

Code Reference


SubmissionMismatch

6002
string
“Matched submission mismatch”

Description

Thrown when the provided BountySubmission account does not match the bounty’s recorded matched_submission field.

Thrown By

Security Note

This check prevents a malicious actor from substituting a different submission during approval. The bounty’s matched_submission field is set atomically in submit_to_bounty and cannot be changed except by approving or closing the bounty.

Code Reference


BountyExpired

6003
string
“Bounty deadline has passed”

Description

Reserved for future use. Currently not thrown by any instruction.

Intended Use

This error code exists for potential future enforcement of bounty deadlines. The NullBounty.deadline field is stored on-chain but not currently validated by the program.

Potential Implementation

A future version might add deadline enforcement in submit_to_bounty:
The frontend currently filters expired bounties based on the deadline field, but the program does not enforce this on-chain.

InvalidRewardAmount

6004
string
“Reward amount must be > 0”

Description

Thrown when attempting to create a bounty with a zero or negative reward amount.

Thrown By

Rationale

A bounty with zero reward provides no incentive and would be pointless. This validation ensures all bounties have economic value.

Code Reference


FeeOverflow

6005
string
“Fee calculation overflow”

Description

Thrown when arithmetic operations during fee calculation result in overflow or underflow.

Thrown By

Security Note

Using checked arithmetic prevents integer overflow attacks. Even though the inputs make overflow practically impossible, defensive programming ensures the program fails safely rather than silently producing incorrect results.

Code Reference


Error Handling in Client Code

Anchor errors can be caught and decoded in TypeScript:

Error Code Summary

All Anchor custom errors automatically include the program ID and instruction context in the transaction error logs, making debugging easier.