Ensure index > 0 for those tricky ones.

This commit is contained in:
Hedden, Kyle Matthew 2023-12-01 14:32:33 -05:00
parent 21f24b2c9b
commit 8b64b2b52a

View File

@ -84,8 +84,8 @@ import VDSColorTokens
// MARK: - TabBarProtocol
@MainActor
public func highlightTab(at index: Int) {
guard let items = items, index < items.count else {
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Tab index \(index) is greater than the number of tabs available \(items?.count ?? 0).", code: 0, domain: ErrorDomainSystem, location: #function)!)
guard let items = items, index >= 0, index < items.count else {
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Invalid tab index \(index). \(items?.count ?? 0) tabs available .", code: 0, domain: ErrorDomainSystem, location: #function)!)
return
}
tabModel.selectedTab = index
@ -94,8 +94,8 @@ import VDSColorTokens
@MainActor
public func selectTab(at index: Int) {
guard let items = items, index < items.count else {
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Tab index \(index) is greater than the number of tabs available \(items?.count ?? 0).", code: 0, domain: ErrorDomainSystem, location: #function)!)
guard let items = items, index >= 0, index < items.count else {
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Invalid tab index \(index). \(items?.count ?? 0) tabs available.", code: 0, domain: ErrorDomainSystem, location: #function)!)
return
}
selectedItem = items[index]