【发布时间】:2014-01-19 11:49:11
【问题描述】:
我有以下引发异常的方法:
@ApiMethod(name = "login")
public Profile getLogin(User user) throws UnauthorizedException {
if (user == null){
throw new UnauthorizedException("missing user");
}
...
}
如何捕捉android客户端AsyncTask中的错误?
protected Profile doInBackground(Void... unused) {
Profile profile = null;
try {
profile = service.login().execute();
} catch (Exception e) {
Log.d("exception", e.getMessage(), e);
}
return profile;
}
上面没有捕捉到 UnauthorizedException。
【问题讨论】:
-
您找到解决方案了吗?试图弄清楚同样的事情。问题是,我认为,当后端抛出异常时 - 后端也会捕获它,并向您发送 HTTP 错误。线索是自定义这个 HTTP 错误..
标签: java android exception google-cloud-endpoints