Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
file_manager: trap the exception if the claim is not a stream
If `claim` is not a stream, the line `claim.stream.source.bt_infohash` will raise a `ValueError` exception because `claim.stream` does not contain a valid object. This will happen if we try to download a claim that is in fact a `collection` (a playlist). ``` lbrynet get collection-music ``` Since at the moment we don't trap this exception, it prints the entire trace of the exception. ``` Traceback (most recent call last): File "/opt/git/lbry-sdk/lbry/file/file_manager.py", line 117, in download_from_uri if claim.stream.source.bt_infohash: File "/opt/git/lbry-sdk/lbry/schema/claim.py", line 55, in stream return Stream(self) File "/opt/git/lbry-sdk/lbry/schema/claim.py", line 108, in __init__ self.message = self.claim.get_message(self.claim_type) File "/opt/git/lbry-sdk/lbry/schema/claim.py", line 46, in get_message raise ValueError(f'Claim is not a {type_name}.') ``` Therefore we will raise `InvalidStreamURLError` if `claim.is_collection` is True or if `claim.is_stream` is False. Later on the code we handle this `InvalidStreamURLError` exception to show the appropriate message. ``` WARNING lbry.file.file_manager:258: Failed to download collection-music: Invalid LBRY stream URL: 'collection-music' WARNING lbry.extras.daemon.daemon:1114: Error downloading collection-music: Claim is not a stream. ```
- Loading branch information