chore: better error message
This commit is contained in:
parent
c6e0c640d9
commit
70ff6d6460
1 changed files with 4 additions and 9 deletions
|
|
@ -27,20 +27,15 @@ func ensureVehicleEx[T any](
|
|||
return zero, fmt.Errorf("cannot get vehicles: %w", err)
|
||||
}
|
||||
|
||||
// vin defined
|
||||
if vin = strings.ToUpper(vin); vin != "" {
|
||||
if vin := strings.ToUpper(vin); vin != "" {
|
||||
// vin defined
|
||||
for _, vehicle := range vehicles {
|
||||
if vin == extract(vehicle) {
|
||||
return vehicle, nil
|
||||
}
|
||||
}
|
||||
|
||||
// vin defined but doesn't exist
|
||||
return zero, fmt.Errorf("cannot find vehicle: %s", vin)
|
||||
}
|
||||
|
||||
// vin empty
|
||||
if len(vehicles) == 1 {
|
||||
} else if len(vehicles) == 1 {
|
||||
// vin empty and exactly one vehicle
|
||||
return vehicles[0], nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue