removed obsolete errors
This commit is contained in:
@@ -146,7 +146,7 @@ func calculateBalance(lines []*model.PostingLine) (decimal.Decimal, error) {
|
||||
for _, line := range lines {
|
||||
amount, err := parseDecimal(line.Amount)
|
||||
if err != nil {
|
||||
return decimal.Zero, fmt.Errorf("invalid line amount: %w", err)
|
||||
return decimal.Zero, merrors.InvalidArgumentWrap(err, "invalid line amount")
|
||||
}
|
||||
balance = balance.Add(amount)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/tech/sendico/ledger/storage"
|
||||
ledgerModel "github.com/tech/sendico/ledger/storage/model"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
pmessaging "github.com/tech/sendico/pkg/messaging"
|
||||
me "github.com/tech/sendico/pkg/messaging/envelope"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
@@ -126,7 +127,7 @@ func (p *outboxPublisher) dispatchPending(ctx context.Context) (int, error) {
|
||||
func (p *outboxPublisher) publishEvent(_ context.Context, event *ledgerModel.OutboxEvent) error {
|
||||
docID := event.GetID()
|
||||
if docID == nil || docID.IsZero() {
|
||||
return errors.New("outbox event missing identifier")
|
||||
return merrors.InvalidArgument("outbox event missing identifier")
|
||||
}
|
||||
|
||||
payload, err := p.wrapPayload(event)
|
||||
@@ -157,7 +158,7 @@ func (p *outboxPublisher) wrapPayload(event *ledgerModel.OutboxEvent) ([]byte, e
|
||||
func (p *outboxPublisher) markSent(ctx context.Context, event *ledgerModel.OutboxEvent) error {
|
||||
eventRef := event.GetID()
|
||||
if eventRef == nil || eventRef.IsZero() {
|
||||
return errors.New("outbox event missing identifier")
|
||||
return merrors.InvalidArgument("outbox event missing identifier")
|
||||
}
|
||||
|
||||
return p.store.MarkSent(ctx, *eventRef, time.Now().UTC())
|
||||
|
||||
@@ -249,15 +249,15 @@ func (s *Service) getStatementResponder(_ context.Context, req *ledgerv1.GetStat
|
||||
func parseCursor(cursor string) (int, error) {
|
||||
decoded, err := base64.StdEncoding.DecodeString(cursor)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid base64: %w", err)
|
||||
return 0, merrors.InvalidArgumentWrap(err, "invalid cursor base64 encoding")
|
||||
}
|
||||
parts := strings.Split(string(decoded), ":")
|
||||
if len(parts) != 2 || parts[0] != "offset" {
|
||||
return 0, fmt.Errorf("invalid cursor format")
|
||||
return 0, merrors.InvalidArgument("invalid cursor format")
|
||||
}
|
||||
offset, err := strconv.Atoi(parts[1])
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("invalid offset: %w", err)
|
||||
return 0, merrors.InvalidArgumentWrap(err, "invalid cursor offset")
|
||||
}
|
||||
return offset, nil
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
|
||||
"github.com/tech/sendico/ledger/storage"
|
||||
"github.com/tech/sendico/pkg/api/routers"
|
||||
"github.com/tech/sendico/pkg/merrors"
|
||||
pmessaging "github.com/tech/sendico/pkg/messaging"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
ledgerv1 "github.com/tech/sendico/pkg/proto/ledger/v1"
|
||||
@@ -241,10 +242,10 @@ func (s *Service) quoteFees(ctx context.Context, trigger feesv1.Trigger, organiz
|
||||
return nil, nil
|
||||
}
|
||||
if strings.TrimSpace(organizationRef) == "" {
|
||||
return nil, fmt.Errorf("organization reference is required to quote fees")
|
||||
return nil, merrors.InvalidArgument("organization reference is required to quote fees")
|
||||
}
|
||||
if baseAmount == nil {
|
||||
return nil, fmt.Errorf("base amount is required to quote fees")
|
||||
return nil, merrors.InvalidArgument("base amount is required to quote fees")
|
||||
}
|
||||
|
||||
amountCopy := &moneyv1.Money{Amount: baseAmount.GetAmount(), Currency: baseAmount.GetCurrency()}
|
||||
@@ -309,11 +310,11 @@ func convertFeeDerivedLines(lines []*feesv1.DerivedPostingLine) ([]*ledgerv1.Pos
|
||||
continue
|
||||
}
|
||||
if line.GetMoney() == nil {
|
||||
return nil, fmt.Errorf("fee line %d missing money", idx)
|
||||
return nil, merrors.Internal(fmt.Sprintf("fee line %d missing money", idx))
|
||||
}
|
||||
dec, err := decimal.NewFromString(line.GetMoney().GetAmount())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fee line %d invalid amount: %w", idx, err)
|
||||
return nil, merrors.InternalWrap(err, fmt.Sprintf("fee line %d invalid amount", idx))
|
||||
}
|
||||
dec = ensureAmountForSide(dec, line.GetSide())
|
||||
posting := &ledgerv1.PostingLine{
|
||||
|
||||
Reference in New Issue
Block a user