Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance error logging in OrderDetailsDataSource #14018

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
- [*] Jetpack setup: fixed issue checking site info after activating Jetpack for sites with Jetpack connection package. [https://github.com/woocommerce/woocommerce-ios/pull/13993]
- [*] Blaze: Campaign status is now updated immediately after being canceled. [https://github.com/woocommerce/woocommerce-ios/pull/13992]
- [*] Now the keyboard will be open automatically when creating a new Product Category. [https://github.com/woocommerce/woocommerce-ios/pull/14031]
- [internal] Logging for app storage size added in Core Data crash logs [https://github.com/woocommerce/woocommerce-ios/pull/14008]
- [*] Payments: Prevent phone from sleeping during card reader updates [https://github.com/woocommerce/woocommerce-ios/pull/14021]
- [internal] Logging for app storage size added in Core Data crash logs [https://github.com/woocommerce/woocommerce-ios/pull/14008]
- [internal] Enhanced error logging in the `OrderDetailsDataSource` class to improve crash diagnostics. [https://github.com/woocommerce/woocommerce-ios/pull/14018]
- [internal] Fixed concurrency issue with Blaze local notification scheduler.
- [internal] Fixed concurrency issue with Blaze local notification scheduler. [https://github.com/woocommerce/woocommerce-ios/pull/14012]
- [internal] We added ability to mark and filter favorite products. This feature isn't released yet. But please smoke test product filtering work as expected. [https://github.com/woocommerce/woocommerce-ios/pull/14001]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,29 @@ final class OrderDetailsDataSource: NSObject {
return nil
}
let shippingLabelIndex = indexPath.section - firstShippingLabelSectionIndex
guard shippingLabelIndex >= 0 && shippingLabelIndex < shippingLabels.count else {
ServiceLocator.crashLogging.logMessage(
"Invalid shippingLabelIndex in OrderDetailsDataSource",
properties: ["shippingLabelIndex": shippingLabelIndex],
level: .warning
)
return nil
}
return shippingLabels[shippingLabelIndex]
}

func shippingLabelOrderItem(at indexPath: IndexPath) -> AggregateOrderItem? {
guard let shippingLabel = shippingLabel(at: indexPath) else {
return nil
}
guard indexPath.row >= 0 && indexPath.row < shippingLabelOrderItemsAggregator.orderItems(of: shippingLabel).count else {
ServiceLocator.crashLogging.logMessage(
"Invalid row index for shippingLabel in OrderDetailsDataSource",
properties: ["rowIndex": indexPath.row, "shippingLabel": shippingLabel],
level: .warning
)
return nil
}
return shippingLabelOrderItemsAggregator.orderItem(of: shippingLabel, at: indexPath.row)
}

Expand All @@ -336,11 +352,36 @@ extension OrderDetailsDataSource: UITableViewDataSource {
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
guard section >= 0 && section < sections.count else {
ServiceLocator.crashLogging.logMessage(
"Invalid number of rows in section - OrderDetailsDataSource",
properties: ["section": section],
level: .error
)
return 0
}
return sections[section].rows.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let row = sections[indexPath.section].rows[indexPath.row]
guard indexPath.section >= 0 && indexPath.section < sections.count else {
ServiceLocator.crashLogging.logMessage(
"Invalid section in cellForRowAtIndexPath in OrderDetailsDataSource",
properties: ["section": indexPath.section],
level: .error
)
return UITableViewCell()
}
let section = sections[indexPath.section]
guard indexPath.row >= 0 && indexPath.row < section.rows.count else {
ServiceLocator.crashLogging.logMessage(
"Invalid row in cellForRowAtIndexPath in OrderDetailsDataSource",
properties: ["row": indexPath.section, "section": indexPath.section],
level: .error
)
return UITableViewCell()
}
let row = section.rows[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: row.reuseIdentifier, for: indexPath)
configure(cell, for: row, at: indexPath)
return cell
Expand All @@ -351,9 +392,15 @@ extension OrderDetailsDataSource: UITableViewDataSource {
// MARK: - Support for UITableViewDelegate
extension OrderDetailsDataSource {
func viewForHeaderInSection(_ section: Int, tableView: UITableView) -> UIView? {
guard let section = sections[safe: section] else {
guard section >= 0 && section < sections.count else {
ServiceLocator.crashLogging.logMessage(
"Invalid section in viewForHeaderInSection in OrderDetailsDataSource",
properties: ["section": section],
level: .error
)
return nil
}
let section = sections[section]

let reuseIdentifier = section.headerStyle.viewType.reuseIdentifier
guard let headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: reuseIdentifier) else {
Expand Down
Loading