Improve exception handling

This commit is contained in:
Bart Sopers 2020-04-29 00:10:53 +02:00
parent b482f0690f
commit a0e5ec74fa
2 changed files with 11 additions and 3 deletions

View file

@ -39,6 +39,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalMessageAddressException;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalMessageSequenceNumberException;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalVersionResponseTypeException;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
@ -607,7 +608,11 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
if (ex instanceof ActionInitializationException || ex instanceof CommandInitializationException) {
comment = getStringResource(R.string.omnipod_driver_error_invalid_parameters);
} else if (ex instanceof CommunicationException) {
comment = getStringResource(R.string.omnipod_driver_error_communication_failed);
if(((CommunicationException) ex).getType() == CommunicationException.Type.TIMEOUT) {
comment = getStringResource(R.string.omnipod_driver_error_communication_failed_timeout);
} else {
comment = getStringResource(R.string.omnipod_driver_error_communication_failed_unexpected_exception);
}
} else if (ex instanceof CrcMismatchException) {
comment = getStringResource(R.string.omnipod_driver_error_crc_mismatch);
} else if (ex instanceof IllegalPacketTypeException) {
@ -615,6 +620,8 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
} else if (ex instanceof IllegalPodProgressException || ex instanceof IllegalSetupProgressException
|| ex instanceof IllegalDeliveryStatusException) {
comment = getStringResource(R.string.omnipod_driver_error_invalid_progress_state);
} else if (ex instanceof IllegalVersionResponseTypeException) {
comment = getStringResource(R.string.omnipod_driver_error_invalid_response);
} else if (ex instanceof IllegalResponseException) {
comment = getStringResource(R.string.omnipod_driver_error_invalid_response);
} else if (ex instanceof IllegalMessageSequenceNumberException) {

View file

@ -1749,9 +1749,10 @@
<string name="omnipod_error_pod_not_attached">No active pod.</string>
<string name="omnipod_driver_error_setup_action_verification_failed">Command verification failed.</string>
<string name="omnipod_driver_error_unexpected_exception_type">An unexpected error occured. Please report! (type: %1$s).</string>
<string name="omnipod_driver_error_unexpected_exception_type">An unexpected error occurred. Please report! (type: %1$s).</string>
<string name="omnipod_driver_error_invalid_parameters">Communication failed: received invalid input parameters.</string>
<string name="omnipod_driver_error_communication_failed">Communication failed.</string>
<string name="omnipod_driver_error_communication_failed_timeout">Communication failed: timeout.</string>
<string name="omnipod_driver_error_communication_failed_unexpected_exception">Communication failed: an unexpected error occurred. Please report!</string>
<string name="omnipod_driver_error_crc_mismatch">Communication failed: message integrity verification failed.</string>
<string name="omnipod_driver_error_invalid_packet_type">Communication failed: received an invalid packet from the Pod.</string>
<string name="omnipod_driver_error_invalid_progress_state">Communication failed: the Pod is in a wrong state.</string>