0

我抛出了一些异常消息,例如:

public static ILSResponseEmailLookUPBO getILSUserAccounts(Resources res,
        String email) throws TripLoggerCustomException,
        TripLoggerUnexpectedErrorException {
    String resp = null;

    String lookupURL;
    try {
        lookupURL = TripLoggerConstants.ServerConstants.ILS_LOOKUP_URL
                + URLEncoder.encode(email, "UTF-8");
    } catch (UnsupportedEncodingException e1) {
        throw new TripLoggerCustomException(
                res.getString(R.string.error_try_again));
    }
    try {
        resp = ConnectionManager.getInstance().httpRequest(lookupURL,
                TripLoggerConstants.RequestMethods.GET);
    } catch (IOException e) {
        if (e.getMessage().equals(
                res.getString(R.string.network_unreachable))
                || e.getMessage().equals(
                        res.getString(R.string.host_unresolved))) {
            throw new TripLoggerCustomException(
                    res.getString(R.string.network_not_reachable));
        } else {
            throw new TripLoggerCustomException(
                    res.getString(R.string.email_notfound_ils));
        }
    }

在这里我的 else 部分执行。我的异常类是:

 public class TripLoggerCustomException extends Exception {

    private String customMessage;
    private static final long serialVersionUID = 1L;

    public TripLoggerCustomException() {
        super();
    }

    public TripLoggerCustomException(String message) {
        super(message);
        this.customMessage = (message == null ? "" : message);
    }

    public String getCustomMessage() {
        return this.customMessage;
    }

    public void setCustomMessage(String customMessage) {
        this.customMessage = customMessage;
    }
     }

在这里我发现了这个异常:

  private void manageLookUpActions(final String emailID) {

    new Thread() {
        public void run() {

            try {
                listILSAccounts = ILSLookupEmailBL.getILSUserAccounts(
                        getResources(), emailID);
            } catch (TripLoggerCustomException e) {
                dismissProgressBar();
                handleException(e.getMessage());
                return;
            } catch (TripLoggerUnexpectedErrorException e) {
                dismissProgressBar();
                handleException(e.getMessage());
                return;
            }
}
    }.start();

}

但在这里抓住的TripLoggerCustomException enull。为什么?谁能帮助我?

4

1 回答 1

0

在查看了有关 StackOverflow 的多个报告后,这似乎不是一个实际问题。很多人一直在说这是Eclipse调试器和Android Emulator结合的问题。e这就是为什么您没有收到 NullPointerException,如果为 null ,您肯定会收到。

因此,这可能不是您必须担心的问题。

于 2013-10-25T15:40:14.483 回答