Bug 722553 - uniformize JPakeClientStage error handling. r=rnewman

This commit is contained in:
Nick Alexander 2012-03-02 17:36:15 -08:00
parent 4163c839f2
commit dda520ec9a
5 changed files with 16 additions and 1 deletions

View File

@ -21,6 +21,7 @@ public class ComputeKeyVerificationStage extends JPakeStage {
if (jClient.myKeyBundle == null) {
Logger.error(LOG_TAG, "KeyBundle has not been set; aborting.");
jClient.abort(Constants.JPAKE_ERROR_INTERNAL);
return;
}
try {
jClient.jOutgoing = computeKeyVerification(jClient.myKeyBundle, jClient.mySignerId);

View File

@ -52,13 +52,16 @@ public class GetChannelStage extends JPakeStage {
@Override
public void handleFailure(String error) {
Logger.error(LOG_TAG, "Got HTTP failure: " + error);
jClient.abort(error);
return;
}
@Override
public void handleError(Exception e) {
Logger.error(LOG_TAG, "Threw HTTP exception.", e);
jClient.abort(Constants.JPAKE_ERROR_CHANNEL);
return;
}
};
@ -67,9 +70,11 @@ public class GetChannelStage extends JPakeStage {
} catch (URISyntaxException e) {
Logger.error(LOG_TAG, "Incorrect URI syntax.", e);
jClient.abort(Constants.JPAKE_ERROR_INVALID);
return;
} catch (Exception e) {
Logger.error(LOG_TAG, "Unexpected exception.", e);
jClient.abort(Constants.JPAKE_ERROR_INTERNAL);
return;
}
}

View File

@ -73,13 +73,16 @@ public class GetRequestStage extends JPakeStage {
@Override
public void handleFailure(String error) {
Logger.error(LOG_TAG, "Got HTTP failure: " + error);
jClient.abort(error);
return;
}
@Override
public void handleError(Exception e) {
Logger.error(LOG_TAG, "Threw HTTP exception.", e);
jClient.abort(Constants.JPAKE_ERROR_NETWORK);
return;
}
};

View File

@ -58,13 +58,16 @@ public class PutRequestStage extends JPakeStage {
@Override
public void handleFailure(String error) {
Logger.error(LOG_TAG, "Got HTTP failure: " + error);
jClient.abort(error);
return;
}
@Override
public void handleError(Exception e) {
Logger.error(LOG_TAG, "HTTP exception.", e);
jClient.abort(Constants.JPAKE_ERROR_NETWORK);
return;
}
};
@ -81,7 +84,9 @@ public class PutRequestStage extends JPakeStage {
try {
putRequest.put(JPakeClient.jsonEntity(jClient.jOutgoing.object));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
Logger.error(LOG_TAG, "UnsupportedEncodingException", e);
jClient.abort(Constants.JPAKE_ERROR_INTERNAL);
return;
}
Logger.debug(LOG_TAG, "Outgoing message: " + jClient.jOutgoing.toJSONString());
}

View File

@ -54,6 +54,7 @@ public class VerifyPairingStage extends JPakeStage {
} else {
Logger.error(LOG_TAG, "Keys don't match.");
jClient.abort(Constants.JPAKE_ERROR_KEYMISMATCH);
return;
}
}