Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

errors.gno

1.29 Kb · 32 lines
 1package namereg
 2
 3import (
 4	"errors"
 5
 6	"gno.land/p/nt/ufmt/v0"
 7)
 8
 9var (
10	ErrNonUserCall     = errors.New("r/gnoland/users: non-user call")
11	ErrPaused          = errors.New("r/gnoland/users: paused")
12	ErrInvalidUsername = errors.New("r/gnoland/users: invalid username")
13
14	// ErrInvalidPayment is the sentinel for "OriginSend amount didn't
15	// match registerPrice." It deliberately omits the price from its
16	// message — the price is read at panic time via errInvalidPayment()
17	// below, so users see the CURRENT price even after governance has
18	// changed it. Tests that match against this error use it as a
19	// substring check via uassert.AbortsWithMessage. (audit finding #13)
20	ErrInvalidPayment = errors.New("r/gnoland/users: invalid payment amount")
21)
22
23// errInvalidPayment returns the panic value for an OriginSend mismatch.
24// Constructed lazily so the formatted price reflects the current value
25// of registerPrice rather than the value frozen at package init time.
26// Replaces the old `ErrInvalidPayment = ufmt.Errorf(...)` package var
27// (audit finding #13) which captured registerPrice once and silently
28// drifted out of date after every ProposeNewRegisterPrice execution.
29func errInvalidPayment() error {
30	return ufmt.Errorf("%s: must send exactly %d ugnot",
31		ErrInvalidPayment.Error(), registerPrice)
32}