Skip to content

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

@edkry

Description

@edkry
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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhEnhancements & new featureshelp welcomeIssues that depend on contributions from new developersreaderRead file formats defined by the SDMX standardswishlistNo current plan or schedule to implement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions