Skip to content

feat: Add error details in onFailed delegate callback#132

Merged
Balamurugan-Testpress merged 6 commits intomainfrom
add_exception_onFailed
Mar 5, 2026
Merged

feat: Add error details in onFailed delegate callback#132
Balamurugan-Testpress merged 6 commits intomainfrom
add_exception_onFailed

Conversation

@Balamurugan-Testpress
Copy link
Contributor

  • Update TPStreamsDownloadDelegate.onFailed to include an Error parameter
  • Propagate system and network errors to the delegate for better debugging

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the error reporting in the TPStreams SDK by including an Error parameter in the onFailed delegate callback. This change allows developers to get more detailed information about download failures, making debugging easier. The pull request also ensures that system and network errors are properly propagated to the delegate.

Highlights

  • Error Handling: The onFailed delegate callback now includes an Error parameter to provide more detailed error information.
  • Debugging: System and network errors are now propagated to the delegate, aiding in debugging download failures.
  • Delegate Update: The TPStreamsDownloadDelegate protocol has been updated to include the error parameter in the onFailed function.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • TPStreamsDownloadDelegate.swift
    • Updated the TPStreamsDownloadDelegate protocol to include the error parameter in the onFailed function.
  • TPStreamsDownloadManager.swift
    • Modified the onFailed delegate callback to include an Error parameter for better debugging.
Activity
  • Updated TPStreamsDownloadDelegate.onFailed to include an Error parameter.
  • Propagated system and network errors to the delegate.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully updates the onFailed delegate callback to include an Error parameter, which significantly improves error reporting and debugging capabilities within the download manager. The changes are well-integrated across the delegate protocol definition, its default implementation, and various call sites where download failures are handled.


LocalOfflineAsset.manager.update(object: localOfflineAsset, with: ["status": Status.failed.rawValue])
tpStreamsDownloadDelegate?.onFailed(offlineAsset: localOfflineAsset.asOfflineAsset())
let downloadError = error ?? TPDownloadError.downloadExecutionFailed(NSError(domain: "TPStreamsSDK", code: -1, userInfo: [NSLocalizedDescriptionKey: "Unknown error"]))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The NSError created here uses a generic code -1 and a description "Unknown error". While functional, it would be beneficial for debugging if the error code was more specific to the context of the failure, or if a more descriptive TPDownloadError case was used directly for truly unknown errors. Consider defining a more specific TPDownloadError case or a more granular NSError code for better error differentiation.

Suggested change
let downloadError = error ?? TPDownloadError.downloadExecutionFailed(NSError(domain: "TPStreamsSDK", code: -1, userInfo: [NSLocalizedDescriptionKey: "Unknown error"]))
let downloadError = error ?? TPDownloadError.downloadExecutionFailed(NSError(domain: "TPStreamsSDK", code: TPDownloadError.unknownExecutionErrorCode, userInfo: [NSLocalizedDescriptionKey: "An unexpected download execution error occurred."]))

tpStreamsDownloadDelegate?.onCanceled(assetId: localOfflineAsset.assetId)
} else if status == Status.failed {
tpStreamsDownloadDelegate?.onFailed(offlineAsset: localOfflineAsset.asOfflineAsset())
let downloadError = error ?? TPDownloadError.downloadExecutionFailed(NSError(domain: "TPStreamsSDK", code: -1, userInfo: [NSLocalizedDescriptionKey: "Download failed"]))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the previous comment, this NSError uses a generic code -1 and a description "Download failed". For consistency and improved debuggability, it's recommended to use a more specific error code or a more detailed description. Also, ensure consistency in the default error messages across different failure points (e.g., "Unknown error" vs. "Download failed").

Suggested change
let downloadError = error ?? TPDownloadError.downloadExecutionFailed(NSError(domain: "TPStreamsSDK", code: -1, userInfo: [NSLocalizedDescriptionKey: "Download failed"]))
let downloadError = error ?? TPDownloadError.downloadExecutionFailed(NSError(domain: "TPStreamsSDK", code: TPDownloadError.downloadFailedErrorCode, userInfo: [NSLocalizedDescriptionKey: "Download failed unexpectedly."]))

@Balamurugan-Testpress Balamurugan-Testpress changed the base branch from download-api-resolution-fallback to main March 5, 2026 09:25
- Enable optional fallback when the requested resolution is unavailable
- Select the closest available resolution when fallback is enabled
- Prefer the lower resolution if multiple options are equally close
- Update TPStreamsDownloadDelegate.onFailed to include an Error parameter
- Propagate system and network errors to the delegate for better debugging
- Map internal SDK failures to TPDownloadError for consistent error reporting
@Balamurugan-Testpress Balamurugan-Testpress merged commit f05428c into main Mar 5, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants