@@ -5,6 +5,7 @@ import passport from "passport";
55import customError from "../utils/interfaces/customError" ;
66import quoteValidation from "../middlewares/validations/quote" ;
77import { isCustomer } from "../middlewares/authMiddleware" ;
8+ import { throwHttpError } from "../utils/constructors/httpError" ;
89
910const router = express . Router ( ) ;
1011
@@ -41,13 +42,7 @@ router.get(
4142 const moverId = user . moverId ; // user.id를 먼저 확인
4243
4344 if ( ! moverId ) {
44- const error : customError = new Error ( "Unauthorized" ) ;
45- error . status = 401 ;
46- error . message = "Unauthorized" ;
47- error . data = {
48- message : "기사 정보를 찾을 수 없습니다." ,
49- } ;
50- throw error ;
45+ return throwHttpError ( 401 , "기사 정보를 찾을 수 없습니다." ) ;
5146 }
5247
5348 // 기본값 설정
@@ -75,13 +70,7 @@ router.get(
7570
7671 // moverId 유효성 검사
7772 if ( ! moverId ) {
78- const error : customError = new Error ( "Bad Request" ) ;
79- error . status = 400 ;
80- error . message = "Bad Request" ;
81- error . data = {
82- message : "기사 ID가 필요합니다." ,
83- } ;
84- throw error ;
73+ return throwHttpError ( 400 , "기사 ID가 필요합니다." ) ;
8574 }
8675
8776 // 쿼리 파라미터 처리 (페이지네이션)
@@ -112,10 +101,7 @@ router.post(
112101
113102 // 파라미터 검증
114103 if ( ! movingRequestId ) {
115- const error : customError = new Error ( "Bad Request" ) ;
116- error . status = 400 ;
117- error . message = "이사 요청 ID가 필요합니다." ;
118- throw error ;
104+ return throwHttpError ( 400 , "이사 요청 ID가 필요합니다." ) ;
119105 }
120106
121107 const result = await quoteService . rejectRequest ( moverId , movingRequestId ) ;
@@ -133,25 +119,13 @@ router.get(
133119 const moverId = user . moverId ;
134120
135121 if ( ! moverId ) {
136- const error : customError = new Error ( "Unauthorized" ) ;
137- error . status = 401 ;
138- error . message = "Unauthorized" ;
139- error . data = {
140- message : "기사 정보를 찾을 수 없습니다." ,
141- } ;
142- throw error ;
122+ return throwHttpError ( 401 , "기사 정보를 찾을 수 없습니다." ) ;
143123 }
144124
145125 const quoteId = parseInt ( req . params . quoteId ) ;
146126
147127 if ( isNaN ( quoteId ) ) {
148- const error : customError = new Error ( "Bad Request" ) ;
149- error . status = 400 ;
150- error . message = "Bad Request" ;
151- error . data = {
152- message : "올바르지 않은 파라미터입니다." ,
153- } ;
154- throw error ;
128+ return throwHttpError ( 400 , "올바르지 않은 파라미터입니다." ) ;
155129 }
156130
157131 const quote = await quoteService . getQuoteDetail ( moverId , quoteId ) ;
0 commit comments