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

Best Answer

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

    image

    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.

Answers

  • 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