Files
cms-website/.deps_siteforge_v812/fastapi/__pycache__/exceptions.cpython-312.pyc
T

142 lines
10 KiB
Plaintext
Raw Normal View History

Ë
ñÅÙj7ãó˜—UddlmZddlmZmZmZmZmZddlm Z ddl
m Z m Z ddl
mZddl
mZGd„ded ¬
«ZGd „d e«ZGd
„de«Ze d«Zee ed<e d«Zee ed<Gd„de«ZGd„de«ZGd„de«ZGd„de«ZGd„de«ZGd„de«ZGd„d e«ZGd!„d"e «Z!y#)$é)ÚSequence)Ú AnnotatedÚAnyÚOptionalÚ TypedDictÚUnion)ÚDoc)Ú BaseModelÚ create_model)Ú
HTTPException)ÚWebSocketExceptioncó6—eZdZUeed<eed<eed<eed<y)ÚEndpointContextÚfunctionÚpathÚfileÚlineN)Ú__name__Ú
__module__Ú __qualname__ÚstrÚ__annotations__Úint©óúVC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\fastapi/exceptions.pyrr
s…؃MØ
ƒIØ
ƒIØ
„IrrF)Útotalc 󌇗eZdZdZ d deeed«fdeeed«fdeee e
e
fed«fd dfˆfd
„
Z ˆxZ S) r a¼
An HTTP exception you can raise in your own code to show errors to the client.
This is for client errors, invalid authentication, invalid data, etc. Not for server
errors in your code.
Read more about it in the
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/).
## Example
```python
from fastapi import FastAPI, HTTPException
app = FastAPI()
items = {"foo": "The Foo Wrestlers"}
@app.get("/items/{item_id}")
async def read_item(item_id: str):
if item_id not in items:
raise HTTPException(status_code=404, detail="Item not found")
return {"item": items[item_id]}
```
NÚ status_codezñ
HTTP status code to send to the client.
Read more about it in the
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#use-httpexception)
Údetaila%
Any data to be sent to the client in the `detail` key of the JSON
response.
Read more about it in the
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#use-httpexception)
Úheaderszþ
Any headers to send to the client in the response.
Read more about it in the
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#add-custom-headers)
Úreturncó*•—t‰|�|||¬«y)N)rr r!©ÚsuperÚ__init__)Úselfrr r!Ú __class__s €rr&zHTTPException.__init__-sø€ôL ‰Ñ [¸ÈÐÕQr)NN)
rrrÚ__doc__rrr rrÚdictrr&Ú
__classcell__©r(s@rr r s§ø„ñðf
ð
ñI&RàØ Ù ðó
ð
ñ

ð&RðØ Ù ðó
ð
ñ 
ð&Rð2Ø �T˜#˜s˜(‘^Ñ $Ù ðó
ð
ñ 
ð3&RðJ
÷K&Rñ&Rrr c ój‡—eZdZdZ d deeed«fdeeedfed«fddfˆfd„
Z ˆxZ
S)
r
a^
A WebSocket exception you can raise in your own code to show errors to the client.
This is for client errors, invalid authentication, invalid data, etc. Not for server
errors in your code.
Read more about it in the
[FastAPI docs for WebSockets](https://fastapi.tiangolo.com/advanced/websockets/).
## Example
```python
from typing import Annotated
from fastapi import (
Cookie,
FastAPI,
WebSocket,
WebSocketException,
status,
)
app = FastAPI()
@app.websocket("/items/{item_id}/ws")
async def websocket_endpoint(
*,
websocket: WebSocket,
session: Annotated[str | None, Cookie()] = None,
item_id: str,
):
if session is None:
raise WebSocketException(code=status.WS_1008_POLICY_VIOLATION)
await websocket.accept()
while True:
data = await websocket.receive_text()
await websocket.send_text(f"Session cookie is: {session}")
await websocket.send_text(f"Message text was: {data}, for item ID: {item_id}")
```
NÚcodez²
A closing code from the
[valid codes defined in the specification](https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1).
Úreasonaw
The reason to close the WebSocket connection.
It is UTF-8-encoded data. The interpretation of the reason is up to the
application, it is not specified by the WebSocket specification.
It could contain text that could be human-readable or interpretable
by the client code, etc.
r"có(•—t‰|�||¬«y)N)r.r/r$)r'r.r/r(s €rr&zWebSocketException.__init__€sø€ô4 ‰Ñ˜d¨6ÐÕ2r©N) rrrr)rrr rrr&r+r,s@rr
r
Vsqø„ñ'ðB
ñ13àØ Ù ðó
ð
ñ
ð3ðØ �#�t�)Ñ Ù ðó
ð
ñ

ð3ð2