For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
12 3 1 2

AttributeError: 'EikonError' object has no attribute 'err_code'

I updated eikon in Python to version 1.1.8 and get the following error when running my code:

                while True:
                    try:
                        loop_screen, error =ek.get_data(each_request,fields)
                        break
                        
                    except ek.EikonError as err:
                        if err.err_code != 2504:
                            # request failed with other reason than 2504 error code
                            break


The error is AttributeError: 'EikonError' object has no attribute 'err_code'.

Could you please help me and tell me what to do?

Thanks

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
6.7k 8 6 7

@FRZH from the reference guide you can see that the EikonError object has the following parameters:

So please try:

while True:
    try:
        loop_screen, error =ek.get_data(each_request,fields)
        ##################################################################
        #I would also suggest an if error: condition here to capture bad #
        #parameters or query requests                                    #
        #A good well returned query should have empty error object       #
        ##################################################################

        if error:
            print(error)
        
        break
    
    #######################################################
    #this exception is thrown from server side
    ########################################################
    except ek.EikonError as err:
        if err.code != 2504:
            # request failed with other reason than 2504 error code
            break

I hope this can help - I have added a further error check to check data return is ok. This will detail any errors with the query itself - but does not throw an exception/EikonError object.


1608141314415.png (52.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
4.3k 2 4 5

Hi,

The right way to get the error code is

                    except ek.EikonError as err:
                         if err.code != 2504:
                             # request failed with other reason than 2504 error code
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea