본문 바로가기

운동하는 개발자/Delphi

델파이 idhttp 에러메세지 내용 확인 / idhttp error message

728x90

idhttp로 통신 중 400대 , 500의 응답코드가 올 때 단순히 에러 메세지를 수집하면
400 Bad Request
500 Internal Server Error
이런식으로만 획득 된다 postman으로 전송해보면 에러 메세지가 리턴와서 확인해보니
서버측에서 보내는 에러 메세지를 확인하는 방법이 있으며 코드는 아래와 같다

    try
      sHttpResult := Http.Post(sUrl, tsArguments);
    except
      on E:EIdHTTPProtocolException do begin
        sHttpResult := E.ErrorMessage;  //예) 1st parameter error
		//e.message    					//예)Bed Request
		//e.errorcode  					//예)400
      end;
    end;

 

728x90