From 85ced969b2bb6ee57bd964b81fc08a9fb28f26f9 Mon Sep 17 00:00:00 2001
From: myunsyeya <myunsyeya@ajou.ac.kr>
Date: Sat, 7 Dec 2024 23:40:54 +0900
Subject: [PATCH] =?UTF-8?q?chore:=20eslint=EC=97=90=20=EB=A7=9E=EA=B2=8C?=
 =?UTF-8?q?=20error=EB=A5=BC=20throw=ED=95=98=EA=B2=8C=20=EB=B3=80?=
 =?UTF-8?q?=EA=B2=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/api/my/updatePCName.js | 51 ++++++++++++++------------------------
 1 file changed, 18 insertions(+), 33 deletions(-)

diff --git a/src/api/my/updatePCName.js b/src/api/my/updatePCName.js
index b2a4d9e..f81d155 100644
--- a/src/api/my/updatePCName.js
+++ b/src/api/my/updatePCName.js
@@ -1,56 +1,41 @@
 import axios from '../axios';
 
 const updatePCName = async (pcId, newName) => {
+  console.log(pcId, newName);
   try {
-    // 입력값 검증
-    if (!newName || !newName.trim()) {
-      throw {
-        response: {
-          data: {
-            message: "잘못된 요청입니다",
-            statusCode: 400,
-            data: {
-              error: "이름은 필수 입력값입니다"
-            }
-          }
-        }
-      };
-    }
-
     const response = await axios.patch(`/my/pc/${pcId}/name`, { 
       name: newName.trim() 
     });
 
-    // 성공 응답 형식에 맞춤
-    return {
-      message: "PC 이름이 성공적으로 변경되었습니다",
-      statusCode: 200,
-      data: {
-        id: pcId,
-        name: newName,
-        updatedAt: new Date().toISOString()
-      }
-    };
+    return response.data;
 
   } catch (error) {
     // 401 Unauthorized 에러 처리
     if (error.response?.status === 401) {
-      throw {
-        message: "인증되지 않은 요청입니다",
-        statusCode: 401,
-        data: {}
+      const unauthorizedError = new Error("인증되지 않은 요청입니다");
+      unauthorizedError.response = {
+        data: {
+          message: "인증되지 않은 요청입니다",
+          statusCode: 401,
+          data: {}
+        }
       };
+      throw unauthorizedError;
     }
 
     // 400 Bad Request 에러 처리
     if (error.response?.status === 400) {
-      throw {
-        message: "잘못된 요청입니다",
-        statusCode: 400,
+      const badRequestError = new Error("잘못된 요청입니다");
+      badRequestError.response = {
         data: {
-          error: "이름은 필수 입력값입니다"
+          message: "잘못된 요청입니다",
+          statusCode: 400,
+          data: {
+            error: "이름은 필수 입력값입니다"
+          }
         }
       };
+      throw badRequestError;
     }
 
     // 기타 에러는 그대로 전달
-- 
GitLab