Skip to content

Commit 99b7dbc

Browse files
committed
refactor: 슬로건 제출 예외 처리 로직 개선
1 parent 481d45e commit 99b7dbc

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/entities/slogan/lib/handleSloganFormSubmit.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import { postSlogan } from "../api/postSlogan";
55
export async function handleSloganFormSubmit(values: SloganFormValues): Promise<boolean> {
66
try {
77
const res = await postSlogan(values);
8-
if (res.status === 200 || res.status === 201) {
9-
toast.success("슬로건이 제출되었습니다.");
10-
return true;
8+
if (res.status !== 200 && res.status !== 201) {
9+
throw new Error(`API request failed with status ${res.status}`);
1110
}
12-
toast.error("슬로건 제출에 실패했습니다.");
13-
return false;
14-
} catch {
11+
toast.success("슬로건이 제출되었습니다.");
12+
return true;
13+
} catch (error) {
1514
toast.error("슬로건 제출에 실패했습니다.");
1615
return false;
1716
}

0 commit comments

Comments
 (0)