mirror of
https://github.com/mskatoni/ni-mail.git
synced 2026-09-04 23:16:44 +08:00
fix: resolve 18-point audit items including http payload error helpers, python-dotenv auto-load, and exception wrapping
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from __future__ import annotations
|
||||
from app.services.http import build_error_payload, get_response_details
|
||||
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
||||
+13
-9
@@ -1,12 +1,16 @@
|
||||
from __future__ import annotations
|
||||
from typing import Any, Dict
|
||||
|
||||
from typing import Any
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def get_response_details(response: requests.Response) -> Any:
|
||||
def get_response_details(res) -> str:
|
||||
try:
|
||||
return response.json()
|
||||
return res.text[:500]
|
||||
except Exception:
|
||||
return response.text or response.reason
|
||||
return "No response details"
|
||||
|
||||
def build_error_payload(code: str, message: str, error_type: str = "APIError", status_code: int = 500, details: Any = None) -> Dict[str, Any]:
|
||||
return {
|
||||
"code": code,
|
||||
"message": message,
|
||||
"type": error_type,
|
||||
"status": status_code,
|
||||
"details": details
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from __future__ import annotations
|
||||
from app.services.http import build_error_payload, get_response_details
|
||||
|
||||
import email
|
||||
import hashlib
|
||||
|
||||
Reference in New Issue
Block a user