(c *gin.Context, err error)
| 83 | } |
| 84 | |
| 85 | func 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, |
no test coverage detected