mirror of
https://github.com/hanzoai/reward.git
synced 2026-11-17 11:54:10 +00:00
Programs of rules over a typed event catalog under five pillars, claims that staff approve, reject or reverse, an append-only points ledger with lifetime and redeemable balances, levels, badges, budgets and caps, a legacy backfill, public profiles with a live README badge, and the seed program. Every act is written once: claims, steps and ledger rows are inserted under hashed ids by a conditional insert, so there is no read-modify-write and no transaction. Credit goes through commerce's POST /v1/billing/credit only. Claude-Session: https://claude.ai/code/session_015XYKLnBbrbajqj1GpRydF8
24 lines
667 B
Go
24 lines
667 B
Go
// Package refuse is the one error for input the engine will not take: a program,
|
|
// a rule, an event or a staff act that is wrong as the caller wrote it. The HTTP
|
|
// layer answers it with 400; everything else is the engine's own fault.
|
|
package refuse
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// Error is a refusal, with the reason a caller can act on.
|
|
type Error struct{ Msg string }
|
|
|
|
func (e Error) Error() string { return e.Msg }
|
|
|
|
// New refuses with a formatted reason.
|
|
func New(format string, a ...any) error { return Error{fmt.Sprintf(format, a...)} }
|
|
|
|
// Is reports whether err is, or wraps, a refusal.
|
|
func Is(err error) bool {
|
|
var e Error
|
|
return errors.As(err, &e)
|
|
}
|