Bootstrap copied BFF and local accounts with public Sendico contracts (#34)

This commit is contained in:
Stephan D committed 2026-09-12 13:37:48 +02:00
1 parent 67dc5b5b1e
commit 7062672a87
556 files changed
+42291 -777

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
package merrors
import "strings"
const (
ReasonLedgerIdempotencyConflict = "LEDGER_IDEMPOTENCY_CONFLICT"
ReasonLedgerCommandIdentityMismatch = "LEDGER_COMMAND_IDENTITY_MISMATCH"
ReasonLedgerAccessViolation = "LEDGER_ACCESS_VIOLATION"
ReasonAccountNotEligible = "ACCOUNT_NOT_ELIGIBLE"
)
var ErrLedgerIdempotencyConflict = Define("ledger.idempotency_conflict")
var ErrLedgerCommandIdentityMismatch = Define("ledger.command_identity_mismatch")
var ErrLedgerAccessViolation = Define("ledger.access_violation")
var ErrAccountNotEligible = Define("account_not_eligible")
func LedgerIdempotencyConflict(msg string) error {
return classifiedError{
base: ErrDataConflict,
code: ErrLedgerIdempotencyConflict,
msg: ledgerErrorMessage(msg, ErrLedgerIdempotencyConflict),
reason: ReasonLedgerIdempotencyConflict,
}
}
func LedgerCommandIdentityMismatch(msg string) error {
return classifiedError{
base: ErrDataConflict,
code: ErrLedgerCommandIdentityMismatch,
msg: ledgerErrorMessage(msg, ErrLedgerCommandIdentityMismatch),
reason: ReasonLedgerCommandIdentityMismatch,
}
}
func LedgerAccessViolation(msg string) error {
return classifiedError{
base: ErrFailedPrecondition,
code: ErrLedgerAccessViolation,
msg: ledgerErrorMessage(msg, ErrLedgerAccessViolation),
reason: ReasonLedgerAccessViolation,
}
}
func AccountNotEligible(msg string) error {
return classifiedError{
base: ErrFailedPrecondition,
code: ErrAccountNotEligible,
msg: ledgerErrorMessage(msg, ErrAccountNotEligible),
reason: ReasonAccountNotEligible,
}
}
func ledgerErrorMessage(msg string, fallback error) string {
msg = strings.TrimSpace(msg)
if msg != "" {
return msg
}
if fallback == nil {
return ""
}
return fallback.Error()
}