diff --git a/mwapi/async_session.py b/mwapi/async_session.py index c02f0ee..4fa92ad 100644 --- a/mwapi/async_session.py +++ b/mwapi/async_session.py @@ -112,6 +112,11 @@ async def _request(self, method, params=None, auth=None): raise ConnectionError(str(e)) from e except aiohttp.TooManyRedirects as e: raise TooManyRedirectsError(str(e)) from e + except APIError: + # Raised above for a JSON 'error' response. Let it propagate with its + # structured .code/.info/.content instead of re-wrapping as RequestError + # below (matches the synchronous Session, which raises it uncaught). + raise except Exception as e: raise RequestError(str(e)) from e