Skip to content

Commit

Permalink
better errors messages in csv parse
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Dec 9, 2021
1 parent 61d3aa6 commit 3268c12
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions politeiawww/cmd/cmsctl/invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,26 @@ func validateParseCSV(data []byte) (*cms.InvoiceInput, error) {
fmt.Errorf("invalid number of line items on line: %v want: %v got: %v",
i, PolicyInvoiceLineItemCount, len(lineContents))
}
lineItemType, ok := LineItemType[strings.ToLower(strings.TrimSpace(lineContents[0]))]
if !ok {
return invInput,
fmt.Errorf("invalid line item type on line: %v", i)
}
hours, err := strconv.Atoi(strings.TrimSpace(lineContents[5]))
if err != nil {
return invInput,
fmt.Errorf("invalid line item hours entered on line: %v", i)
fmt.Errorf("invalid hours (%v) entered on line: %v", lineContents[5], i)
}
cost, err := strconv.Atoi(strings.TrimSpace(lineContents[6]))
if err != nil {
return invInput,
fmt.Errorf("invalid cost entered on line: %v", i)
fmt.Errorf("invalid cost (%v) entered on line: %v", lineContents[6], i)
}
rate, err := strconv.Atoi(strings.TrimSpace(lineContents[8]))
if err != nil {
return invInput,
fmt.Errorf("invalid subrate hours (%v) entered on line: %v", lineContents[8], i)
}
lineItemType, ok := LineItemType[strings.ToLower(strings.TrimSpace(lineContents[0]))]
if !ok {
return invInput,
fmt.Errorf("invalid line item type on line: %v", i)
}

lineItem.Type = lineItemType
lineItem.Domain = strings.TrimSpace(lineContents[1])
Expand Down

0 comments on commit 3268c12

Please sign in to comment.