MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / handleRecordTransactionValidationError

Function handleRecordTransactionValidationError

api/transactions.go:85–100  ·  view source on GitHub ↗
(c *gin.Context, err error)

Source from the content-addressed store, hash-verified

83}
84
85func handleRecordTransactionValidationError(c *gin.Context, err error) {
86 var validationErrors validation.Errors
87 if errors.As(err, &validationErrors) {
88 if precisionErr, ok := validationErrors["Precision"]; ok && errors.Is(precisionErr, model2.ErrPrecisionMustBeInteger) {
89 c.JSON(http.StatusBadRequest, gin.H{"error": precisionErr.Error()})
90 return
91 }
92 }
93
94 if errors.Is(err, model2.ErrPrecisionMustBeInteger) {
95 c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
96 return
97 }
98
99 c.JSON(http.StatusBadRequest, gin.H{"errors": err.Error()})
100}
101
102// RecordTransaction handles the recording of a new transaction.
103// It binds the incoming JSON request to a RecordTransaction object, validates it,

Callers 2

RecordTransactionMethod · 0.85
QueueTransactionMethod · 0.85

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected