我试过了
public void onFailure(Throwable caught) {
Throwable cause = caught.getCause();
String causeStr = (cause==null) ? "" : ", "+cause.getMessage();
errorLabel.setText(SERVER_ERROR + ": " + caught.getMessage() + causeStr);
但是 cause 总是 null 并且caught.getMessage()
总是等于非常通用的500 The call failed on the server; see server log for details
. 我想从服务器抛出 IllegalArgumentExceptions 并能够在客户端上显示它:
throw new IllegalArgumentException("Email address is invalid.");