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

Add Files class for upload/download files #781

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

ludeeus
Copy link
Contributor

@ludeeus ludeeus commented Jan 21, 2025

Adds a new Files class to handle the communication related to files.

Eventually, all file-related functions would be moved into this new class.
But as a start, it now contains the upload and download handling.
Cleaning up the old stuff will be done in a separate PR.

@ludeeus ludeeus marked this pull request as ready for review January 21, 2025 11:18
except TimeoutError as err:
raise FilesError("Timeout reached while trying to download file") from err
except ClientError as err:
raise FilesError("Failed to download file") from err
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe include the response status code in the error message? Ie catch ClientResponseError separately and then ClientError. For the ClientError case maybe include the exception in the message string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not suited for MVP.

Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the exception to the message for ClientError is just a change on this line.

resp.url.path if resp.url.host == self._cloud.servicehandlers_server else ""
)
_LOGGER.log(
logging.DEBUG if isok else logging.WARNING,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd include these details in the exception message and let consumers decide how to log it. Ie always log only at debug level here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not suited for MVP.

if data is None:
raise FilesError("Failed to parse response from files handler") from None

resp.raise_for_status()
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we raise before we try parsing the response?

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.

3 participants