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

How i can catch the exceptions #456

Open
ahmedsafadii opened this issue Jun 13, 2024 · 1 comment
Open

How i can catch the exceptions #456

ahmedsafadii opened this issue Jun 13, 2024 · 1 comment

Comments

@ahmedsafadii
Copy link

How i can catch the exceptions for example if the summoner is not found and I want to catch it so I can return a custom message.

def test():

lol_manager = LolManager()
puuid = "ovqw2cGBNvqhlGZV3u1lBWmROrfXVTnjjAfoOd5GN-e_YeTGnVossVzw84Z_GDHpvgDC_fVJ3FQACg1"
server = "EUW"
try:
    summoner = lol_manager.get_summoner_by_puuid(puuid=puuid, region=server)
    print("Summoner found:", summoner.account_id)
except HTTPError as e:
    print("HTTP error:", e)
except Exception as e:
    print("An unexpected error occurred:", e)

my settings

settings = {
            "RiotAPI": {
                "api_key": RIOT_API_KEY,
                "request_error_handling": {
                    "404": {"strategy": "throw"},
                    "429": {
                        "service": {
                            "strategy": "exponential_backoff",
                            "initial_backoff": 1.0,
                            "backoff_factor": 2.0,
                            "max_attempts": 4,
                        },
                        "method": {"strategy": "retry_from_headers", "max_attempts": 5},
                        "application": {
                            "strategy": "retry_from_headers",
                            "max_attempts": 5,
                        },
                    },
                    "500": {
                        "strategy": "exponential_backoff",
                        "initial_backoff": 1.0,
                        "backoff_factor": 2.0,
                        "max_attempts": 4,
                    },
                    "503": {
                        "strategy": "exponential_backoff",
                        "initial_backoff": 1.0,
                        "backoff_factor": 2.0,
                        "max_attempts": 8,
                    },
                    "timeout": {"strategy": "throw"},
                    "403": {"strategy": "throw"},
                    "504": {
                        "strategy": "exponential_backoff",
                        "initial_backoff": 1.0,
                        "backoff_factor": 2.0,
                        "max_attempts": 4,
                    },
                    "502": {
                        "strategy": "exponential_backoff",
                        "initial_backoff": 1.0,
                        "backoff_factor": 2.0,
                        "max_attempts": 4,
                    },
                },
            }
        }
        ```
@machimozor
Copy link

Hey, can you assign me this issue please !

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

No branches or pull requests

2 participants