Linting rules
E036: throw-requires-documented-error-value
Requires documentation for enum values used as `throw` codes.
Metadata
Code:E036Rule:throw-requires-documented-error-valueStatus: Preview sincev0.0.1Quick fix: not available
What it does
Requires documentation for enum values used as throw codes.
Why is this bad?
Symbolic exit codes become part of the contract interface. Without a short note on the enum value, callers and tests can see the name but not the exact failure condition it represents.
Example
enum Errors {
NotOwner = 401
}
fun onInternalMessage(in: InMessage) {
// ...
assert (in.senderAddress == storage.ownerAddress) throw Errors.NotOwner;
}Use instead:
enum Errors {
/// Sender is not the current owner.
NotOwner = 401
}
fun onInternalMessage(in: InMessage) {
// ...
assert (in.senderAddress == storage.ownerAddress) throw Errors.NotOwner;
}Last updated on