fix: 링크 저장 및 에러 메시지 개선
- created_at 기본값이 없어도 저장되도록 NOW()로 기록 - API 오류 발생 시 detail을 함께 표시 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
3
app.py
3
app.py
@@ -238,7 +238,8 @@ def add_link():
|
|||||||
with get_db_connection() as conn:
|
with get_db_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
f"INSERT INTO {table} (url) VALUES (%s) RETURNING id, created_at",
|
# created_at에 DEFAULT가 없더라도 저장되도록 NOW()를 함께 기록
|
||||||
|
f"INSERT INTO {table} (url, created_at) VALUES (%s, NOW()) RETURNING id, created_at",
|
||||||
(url,),
|
(url,),
|
||||||
)
|
)
|
||||||
link_id, created_at = cur.fetchone()
|
link_id, created_at = cur.fetchone()
|
||||||
|
|||||||
@@ -118,7 +118,8 @@ async function loadNextPage() {
|
|||||||
const res = await fetch(`/links?limit=${PAGE_SIZE}&offset=${nextOffset}`);
|
const res = await fetch(`/links?limit=${PAGE_SIZE}&offset=${nextOffset}`);
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(data.error || "링크를 불러오지 못했습니다.");
|
const detail = data?.detail ? ` (${data.detail})` : "";
|
||||||
|
throw new Error((data.error || "링크를 불러오지 못했습니다.") + detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
const items = Array.isArray(data) ? data : data.items || [];
|
const items = Array.isArray(data) ? data : data.items || [];
|
||||||
@@ -164,7 +165,8 @@ linkForm.addEventListener("submit", async (event) => {
|
|||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error(data.error || "저장에 실패했습니다.");
|
const detail = data?.detail ? ` (${data.detail})` : "";
|
||||||
|
throw new Error((data.error || "저장에 실패했습니다.") + detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetPagination();
|
resetPagination();
|
||||||
|
|||||||
Reference in New Issue
Block a user