Terrance/SkPy

How to use SkypeAuthException for creating Tkinter `messagebox.showerror` ?

Closed this issue · 1 comments

Hello once again :)
I'm trying to create a message box that will display information about the wrong login/password in my Tkinter GUI.
The problem is, I need to manifest this information window only when this particular type of error occurs.
If I understand it correctly the error name is: SkypeAuthException.

Account type

Live (Microsoft) account.

My code posted below is a part of the definition that is linked to the button that allows sending messages in my GUI. The action of the "sending messages" button needs login and pass to skype.

def submit_offers_to_selected_clients():
    
    """
    Because I need a login and a password to access
    the Skype platform before sending messages to clients,
    I need to confirm that these are proper. If they aren't I need to create
    the error message box
    """
    try:
        tk.messagebox.showerror("We can’t sign you!", "Your login or password is not correct. Try to fix it.")

#    except SkypeApiException:
    except SkypeAuthException:     
         tk.messagebox.showerror("We can’t sign you!", "Your login or password is not correct. Try to fix it.")

Problem: When I place proper login and pass and try to send messages(offers) the tk.messagebox.showerror is activated, because another error raised.

This "another error" should be ok ( I have an except module for it and things related to this one needs to stay as they are). Because of that "another error" issue, I've tried to create try except statements to activate tk.messagebox.showerror only when SkypeAuthException appears. But neither SkypeAuthException nor SkypeApiException seems to work. I assume that tk.messagebox.showerror catch every error (this is at least one problem. I couldn't find any info on how can I set it in such a way so it will react only on one type of error). If I knew how to do this I would. But, I don't know and because of that, I tried to use the try except statements, also, without a success.

If you need more info on why I did some except modules for another exceptions:
I have a list of users in an excel file (two columns: one for username, one for group username).
Sometimes I have a user that is also in some group ( then he is in two columns). But, in many cases, I have just a user login. Then the column of "group username" is empty. Because my code tries to send messages from every cell in every row, when it discovers NaN then it throws an error. Another case is when I have two users from one company, so I place one of them into the first column and another one in to "group username" column. My code handles the situation wherein group chat column there is a need to send a "single message" by sk.contacts[LOGIN].chat, but in this case, also, the error is raised ( because it can't send the message via sk.chats.

I'm not really clear on how the problem relates to SkPy -- based on this:

the tk.messagebox.showerror is activated, because another error raised.

...you're saying your code is throwing a non-SkPy error? You haven't provided any details on what this error is, but ultimately this seems like a question on how to handle errors in Tkinter, which doesn't belong here. Consider asking a more general Python community for help, such as /r/LearnPython or Python Discord.