@@ -105,14 +105,36 @@ export class LottoService implements LottoServiceInterface {
105105 return page . getCookies ( ) ;
106106 }
107107
108+ // 디버깅 정보 수집
109+ const debugInfo = {
110+ currentUrl,
111+ isStillOnLoginPage : currentUrl . includes ( URLS . LOGIN ) ,
112+ hasErrorPopup : await page . exists ( SELECTORS . LOGIN_ERROR_POPUP ) ,
113+ hasLoginButton : await page . exists ( SELECTORS . LOGIN_BUTTON ) ,
114+ hasIdInput : await page . exists ( SELECTORS . ID_INPUT ) ,
115+ errorPopupMessage : null as string | null
116+ } ;
117+
118+ // 에러 팝업 메시지 추출 시도
119+ if ( debugInfo . hasErrorPopup ) {
120+ try {
121+ const messages = await page . querySelectorAll ( SELECTORS . LOGIN_ERROR_POPUP , elems =>
122+ elems . map ( el => el . innerHTML . replace ( / < [ ^ > ] * > / g, ' ' ) . trim ( ) )
123+ ) ;
124+ debugInfo . errorPopupMessage = messages . join ( ' | ' ) ;
125+ } catch {
126+ debugInfo . errorPopupMessage = '[failed to extract]' ;
127+ }
128+ }
129+
108130 // 실패: 로그인 에러 팝업 확인
109131 if ( await page . exists ( SELECTORS . LOGIN_ERROR_POPUP , CONST . LOGIN_ERROR_MESSAGE ) ) {
110- this . logger . info ( '[signIn]' , 'failed' , 'credentials incorrect' ) ;
132+ this . logger . info ( '[signIn]' , 'failed' , 'credentials incorrect' , debugInfo ) ;
111133 throw LottoError . CredentialsIncorrect ( ) ;
112134 }
113135
114136 // 기타 실패
115- this . logger . info ( '[signIn]' , 'failed' , 'unknown' ) ;
137+ this . logger . warn ( '[signIn]' , 'failed' , 'unknown reason' , debugInfo ) ;
116138 throw LottoError . CredentialsIncorrect ( ) ;
117139 } ;
118140
0 commit comments