@@ -168,9 +168,9 @@ func writeMatrixToFile(matrix types.ComMatrix, fileName, format string, printFn
168
168
169
169
// GenerateMatrixDiff generates the diff between mat1 to mat2.
170
170
func GenerateMatrixDiff (mat1 types.ComMatrix , mat2 types.ComMatrix ) (string , error ) {
171
- colNames := getComMatrixHeadersByFormat (types .FormatCSV )
172
- if colNames == "" {
173
- return "" , fmt .Errorf ("error getting commatrix CSV tags" )
171
+ colNames , err := getComMatrixHeadersByFormat (types .FormatCSV )
172
+ if err != nil {
173
+ return "" , fmt .Errorf ("error getting commatrix CSV tags: %v" , err )
174
174
}
175
175
176
176
diff := colNames + "\n "
@@ -201,19 +201,20 @@ func GenerateMatrixDiff(mat1 types.ComMatrix, mat2 types.ComMatrix) (string, err
201
201
return diff , nil
202
202
}
203
203
204
- func getComMatrixHeadersByFormat (format string ) string {
204
+ func getComMatrixHeadersByFormat (format string ) ( string , error ) {
205
205
typ := reflect .TypeOf (types.ComDetails {})
206
206
207
207
var tagsList []string
208
208
for i := 0 ; i < typ .NumField (); i ++ {
209
209
field := typ .Field (i )
210
210
tag := field .Tag .Get (format )
211
- if tag ! = "" {
212
- tagsList = append ( tagsList , tag )
211
+ if tag = = "" {
212
+ return "" , fmt . Errorf ( "field %v has not tag of format %s" , field , format )
213
213
}
214
+ tagsList = append (tagsList , tag )
214
215
}
215
216
216
- return strings .Join (tagsList , "," )
217
+ return strings .Join (tagsList , "," ), nil
217
218
}
218
219
219
220
func separateMatrixByRole (matrix types.ComMatrix ) (types.ComMatrix , types.ComMatrix ) {
0 commit comments