Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita7e4f1f

Browse files
committed
Enhance error response
1 parent4e0086c commita7e4f1f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎fastcaddy/core.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ def pcfg(d, path='/', method='post'):
7070
"Puts the config `d` into `path`"
7171
f=getattr(httpx,method)
7272
response=f(get_path(path),json=obj2dict(d))
73-
ifresponse.status_code!=200:print(response.status_code,response.text)
74-
response.raise_for_status()
73+
try:response.raise_for_status()
74+
exceptExceptionase:
75+
e.add_note(f'{response.status_code=}{json.loads(response.text)}')
76+
raise
7577
returnresponse.textorNone
7678

7779
# %% ../nbs/00_core.ipynb 18

‎nbs/00_core.ipynb‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@
214214
"\"Puts the config `d` into `path`\"\n",
215215
" f = getattr(httpx, method)\n",
216216
" response = f(get_path(path), json=obj2dict(d))\n",
217-
" if response.status_code != 200: print(response.status_code, response.text)\n",
218-
" response.raise_for_status()\n",
217+
" try: response.raise_for_status()\n",
218+
" except Exception as e:\n",
219+
" e.add_note(f'{response.status_code=} {json.loads(response.text)}')\n",
220+
" raise\n",
219221
" return response.text or None"
220222
]
221223
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp