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

Provide more logging and raise exception when xml file is empty #172

Open
edkry opened this issue Apr 9, 2024 · 3 comments
Open

Provide more logging and raise exception when xml file is empty #172

edkry opened this issue Apr 9, 2024 · 3 comments
Labels
enh Enhancements & new features help welcome Issues that depend on contributions from new developers reader Read file formats defined by the SDMX standards wishlist No current plan or schedule to implement

Comments

@edkry
Copy link

edkry commented Apr 9, 2024

ecb = sdmx.Client("ECB", backend="memory")
params = dict(startPeriod="2024")
data_msg = ecb.data("ICB", params=params)

This runs but gives an error:

File [~/.local/lib/python3.10/site-packages/sdmx/client.py:496](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/ek/DataLab/lsd/~/.local/lib/python3.10/site-packages/sdmx/client.py:496) in get
    msg = reader.read_message(response_content, structure=kwargs.get("dsd", None))
...
...
...
XMLSyntaxError: no element found

What happens is that ICB table is empty for 2024:
https://data-api.ecb.europa.eu/service/data/ICB?startPeriod=2024

My suggestion is to add additional check before using the reader to read message:

if len(response_content) == 0: 
    raise exception(with meaningful text)
msg = reader.read_message(response_content, structure=kwargs.get("dsd", None))
@khaeru khaeru added enh Enhancements & new features reader Read file formats defined by the SDMX standards help welcome Issues that depend on contributions from new developers wishlist No current plan or schedule to implement labels Apr 10, 2024
@khaeru
Copy link
Owner

khaeru commented Apr 10, 2024

Hi—thanks, this would indeed be a nice convenience feature for users. A PR would be welcome.

Could you expand a bit more about where specifically you'd like more logging? There are already many log messages created. Which code should log which information?

@edkry
Copy link
Author

edkry commented Apr 11, 2024

I can make a PR for sure, would be happy to.

I am thinking what would be the best approach. Logging is not that necessary, raising an exception would be nice, so you can catch it. However, it would be better to return just None if len(response_content) == 0.

What do you think?

@edkry
Copy link
Author

edkry commented Apr 11, 2024

Opened a PR to start a discussion on possible change.

#174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh Enhancements & new features help welcome Issues that depend on contributions from new developers reader Read file formats defined by the SDMX standards wishlist No current plan or schedule to implement
Projects
None yet
Development

No branches or pull requests

2 participants