2
(겉으로보기에는) 잘 알려진 웹 서비스를 호출하는 간단한 정적 메서드입니다.Play Framework 2.2 (java) WS 복구 블록이 HTTP 예외를 catch하지 않습니다.
일치하는 레코드가 없지만 호출의 복구 블록이 실행되지 않으면 서비스에서 HTTP 500/내부 서버 오류를 반환합니다.
나는 명백한 것이 없거나 뻔뻔스럽게 바보 같은 짓을하고 있습니까?
public static Promise<Property> ByPhone(String phone) {
return WS.url("http://localhost:9000/data/property/" + phone)
.get()
.map (
new Function<WS.Response, Property>() {
public Property apply (WS.Response response) {
System.out.println("got here: " + response.getStatusText());
Property property = null;
try {
property = _mapper.readValue(response.getBody(), Property.class);
} catch (Throwable t) {
t.printStackTrace();
}
return property;
}
}
).recover (
new Function<Throwable, Property>() {
public Property apply (Throwable t) {
System.out.println("never get here");
t.printStackTrace();
return null;
}
}
);
}
Bah, spot on. 클라이언트가 서버 예외를 발생시키는 .NET 사고에서 잡아 당깁니다. 걷어차는 것에 감사드립니다. Sorta는 서버가 접근 가능하지 않고 DID 불을 복구 할 때 그것을 알아 냈지만 그것을 증명하기 위해 파고 들지 않았습니다. – brmore