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

Upgrade SteamAuthenticatorError to have the eresult available where available. #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luckydonald
Copy link

See #357.

@@ -54,7 +54,7 @@
from time import time
from steam import webapi
from steam.enums import ETwoFactorTokenType
from steam.steamid import SteamID
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was an unused import.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, unless documentation for the android generate_device_id method actually needs that...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to leave unrelated changes out of this PR

def __init__(self, message, eresult=None):
Exception.__init__(self, message, eresult)
self.message = message
self.eresult = EResult(eresult) if eresult is not None else None #: :class:`.EResult`|:class:`None`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have plenty cases where there's no EResult available.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these is not needed. Simply inherit from SteamError. Don't set eresult to None where there is not result. Just leave the default.

def __init__(self, message, eresult=None):
Exception.__init__(self, message, eresult)
self.message = message
self.eresult = EResult(eresult) if eresult is not None else None #: :class:`.EResult`|:class:`None`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these is not needed. Simply inherit from SteamError. Don't set eresult to None where there is not result. Just leave the default.

@@ -54,7 +54,7 @@
from time import time
from steam import webapi
from steam.enums import ETwoFactorTokenType
from steam.steamid import SteamID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to leave unrelated changes out of this PR

raise SteamAuthenticatorError("MobileWebAuth instance not logged in")
raise SteamAuthenticatorError(
message="MobileWebAuth instance not logged in",
eresult=None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where eresult is not available, simply don't set it. Default is EResult.Fail.

@luckydonald
Copy link
Author

Hi not really much like to fake an API response just for the sake of having that default there.
Like that Eresult has the meaning that it is coming from the API, and I would love to distinguish those errors not directly based on network traffic.

@rossengeorgiev
Copy link
Contributor

I see it as extending and reusing the concepts established by Steam. Some of these errors are generated by the library itself and it doesn't make sense to have different set of errors given the Steam ones are already detailed enough. Generally, any failure in Steam results in a EResult.Fail, so it seem intuitive to have the as default for an exception with an option to specify a more appropriate value.

Additionally, it makes this change from minor enhancement to breaking change. Any code expecting to only get numerical value of eresult property now has to handle None.

@luckydonald
Copy link
Author

That is an issue, I see that. How about adding a separate EResult code, like -1 for that?
I really want to separate library issues from api issues, otherwise we have not gained much.

Or I can simply drop the subclassing and then having None is no issue at all.

@rossengeorgiev
Copy link
Contributor

  1. I don't see any benefit in having that separation
  2. The library doesn't do such separation elsewhere
  3. Fail is a generic catch all which good enough
  4. Introducing exceptions will introduce complexity for anything using the library. Special values like -1 carry risk if Steam decides to make use of them in the future

Any library specific errors can simply be handled defining more exceptions, which is the native way of doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants