fix(client): 处理HTTP 401错误并抛出特定认证异常
当请求返回401状态码时,现在会抛出AuthError而非通用的ITickError,以更清晰地区分认证失败与其他请求错误。
This commit is contained in:
1 parent
409ab94bcc
commit
9d858d3553
1 file changed
+4
@@ -42,6 +42,10 @@ class Client:
|
||||
|
||||
return res_json.get("data")
|
||||
|
||||
except requests.exceptions.HTTPError as e:
|
||||
if e.response.status_code == 401:
|
||||
raise AuthError(f"Authentication failed: {str(e)}")
|
||||
raise ITickError(f"Request failed: {str(e)}")
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise ITickError(f"Request failed: {str(e)}")
|
||||
except ValueError:
|
||||
|
||||
Reference in new issue
Block a user