Skip to content

Commit

Permalink
✨ Use raise from e when load drive error
Browse files Browse the repository at this point in the history
  • Loading branch information
shoucandanghehe committed Feb 8, 2023
1 parent 6d7435b commit 007cfa0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nonebot/drivers/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

try:
import aiohttp
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install aiohttp first to use this driver. `pip install nonebot2[aiohttp]`"
) from None
) from e


class Mixin(ForwardMixin):
Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
from fastapi.responses import Response
from fastapi import FastAPI, Request, UploadFile, status
from starlette.websockets import WebSocket, WebSocketState, WebSocketDisconnect
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install FastAPI by using `pip install nonebot2[fastapi]`"
) from None
) from e


def catch_closed(func):
Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/httpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

try:
import httpx
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install httpx by using `pip install nonebot2[httpx]`"
) from None
) from e


class Mixin(ForwardMixin):
Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
from quart import Quart, Request, Response
from quart.datastructures import FileStorage
from quart import Websocket as QuartWebSocket
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install Quart by using `pip install nonebot2[quart]`"
) from None
) from e

_AsyncCallable = TypeVar("_AsyncCallable", bound=Callable[..., Coroutine])

Expand Down
4 changes: 2 additions & 2 deletions nonebot/drivers/websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
try:
from websockets.exceptions import ConnectionClosed
from websockets.legacy.client import Connect, WebSocketClientProtocol
except ImportError: # pragma: no cover
except ImportError as e: # pragma: no cover
raise ImportError(
"Please install websockets by using `pip install nonebot2[websockets]`"
) from None
) from e

logger = logging.Logger("websockets.client", "INFO")
logger.addHandler(LoguruHandler())
Expand Down

0 comments on commit 007cfa0

Please sign in to comment.