File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,6 +65,17 @@ class LpdbError(Exception):
6565 pass
6666
6767
68+ class LpdbRateLimitError (LpdbError ):
69+ """
70+ Raised when the LPDB request created a fatal issue.
71+ """
72+
73+ def __init__ (self , wiki : str , table : str , * args ):
74+ super ().__init__ (f'Rate limit reached for table "{ table } " in "{ wiki } "' )
75+ self .wiki = wiki
76+ self .table = table
77+
78+
6879class LpdbWarning (Warning ):
6980 """
7081 Warnings about LPDB response.
@@ -272,6 +283,14 @@ def _parse_results(response: LpdbResponse) -> list[dict[str, Any]]:
272283 lpdb_errors = response .get ("error" )
273284
274285 if lpdb_errors and len (lpdb_errors ) != 0 :
286+ rate_limit = re .match (
287+ r"API key \"[0-9A-Za-z]+\" limits for wiki \"(?P<wiki>[a-z]+)\" and table \"(?P<table>[a-z]+)\" exceeded\." ,
288+ lpdb_errors [0 ],
289+ )
290+ if rate_limit :
291+ raise LpdbRateLimitError (
292+ wiki = rate_limit .group ("wiki" ), table = rate_limit .group ("table" )
293+ )
275294 raise LpdbError (re .sub (r"^Error: ?" , "" , lpdb_errors [0 ]))
276295 if lpdb_warnings and len (lpdb_warnings ) != 0 :
277296 for lpdb_warning in lpdb_warnings :
You can’t perform that action at this time.
0 commit comments