Acton
Linting rules

E036: throw-requires-documented-error-value

Requires documentation for enum values used as `throw` codes.

Metadata

  • Code: E036
  • Rule: throw-requires-documented-error-value
  • Status: Preview since v0.0.1
  • Quick 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;
}
Source code

Last updated on

On this page