add failure certainty to OmnipodException

This commit is contained in:
Bart Sopers 2019-11-30 20:12:26 +01:00
parent 0e8baedc8b
commit 8dcadd7a35
16 changed files with 78 additions and 4 deletions

View file

@ -341,12 +341,14 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
// Shouldn't be reachable // Shouldn't be reachable
comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName()); comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName());
} }
if (loggingEnabled()) {
LOG.error(String.format("Caught OmnipodException[certainFailure=%s] from OmnipodManager (user-friendly error message: %s)", ((OmnipodException) ex).isCertainFailure(), comment), ex);
}
} else { } else {
comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName()); comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName());
} if (loggingEnabled()) {
LOG.error(String.format("Caught unexpected exception type from OmnipodManager (user-friendly error message: %s)", comment), ex);
if (loggingEnabled()) { }
LOG.error(String.format("Caught OmnipodManager exception (user-friendly error message: %s)", comment), ex);
} }
return comment; return comment;

View file

@ -4,4 +4,9 @@ public class ActionInitializationException extends OmnipodException {
public ActionInitializationException(String message) { public ActionInitializationException(String message) {
super(message); super(message);
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -4,4 +4,9 @@ public class CommandInitializationException extends OmnipodException {
public CommandInitializationException(String message) { public CommandInitializationException(String message) {
super(message); super(message);
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -17,6 +17,11 @@ public class CommunicationException extends OmnipodException {
return type; return type;
} }
@Override
public boolean isCertainFailure() {
return false;
}
public enum Type { public enum Type {
TIMEOUT("Communication timeout"), TIMEOUT("Communication timeout"),
UNEXPECTED_EXCEPTION("Caught an unexpected Exception"); UNEXPECTED_EXCEPTION("Caught an unexpected Exception");

View file

@ -19,4 +19,9 @@ public class CrcMismatchException extends OmnipodException {
public int getActual() { public int getActual() {
return actual; return actual;
} }
@Override
public boolean isCertainFailure() {
return false;
}
} }

View file

@ -22,4 +22,9 @@ public class IllegalDeliveryStatusException extends OmnipodException {
public DeliveryStatus getActual() { public DeliveryStatus getActual() {
return actual; return actual;
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -22,4 +22,9 @@ public class IllegalPacketTypeException extends OmnipodException {
public PacketType getActual() { public PacketType getActual() {
return actual; return actual;
} }
@Override
public boolean isCertainFailure() {
return false;
}
} }

View file

@ -21,4 +21,9 @@ public class IllegalPodProgressException extends OmnipodException {
public PodProgressStatus getActual() { public PodProgressStatus getActual() {
return actual; return actual;
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -22,4 +22,9 @@ public class IllegalResponseException extends OmnipodException {
public MessageBlockType getExpectedType() { public MessageBlockType getExpectedType() {
return expectedType; return expectedType;
} }
@Override
public boolean isCertainFailure() {
return false;
}
} }

View file

@ -21,4 +21,9 @@ public class IllegalSetupProgressException extends OmnipodException {
public SetupProgress getActual() { public SetupProgress getActual() {
return actual; return actual;
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -8,4 +8,9 @@ public class MessageDecodingException extends OmnipodException {
public MessageDecodingException(String message, Throwable cause) { public MessageDecodingException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
@Override
public boolean isCertainFailure() {
return false;
}
} }

View file

@ -4,4 +4,9 @@ public class NonceResyncException extends OmnipodException {
public NonceResyncException() { public NonceResyncException() {
super("Nonce resync failed"); super("Nonce resync failed");
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -13,4 +13,9 @@ public class NotEnoughDataException extends OmnipodException {
public byte[] getData() { public byte[] getData() {
return data; return data;
} }
@Override
public boolean isCertainFailure() {
return false;
}
} }

View file

@ -8,4 +8,6 @@ public abstract class OmnipodException extends RuntimeException {
public OmnipodException(String message, Throwable cause) { public OmnipodException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }
public abstract boolean isCertainFailure();
} }

View file

@ -16,4 +16,9 @@ public class PodFaultException extends OmnipodException {
public PodInfoFaultEvent getFaultEvent() { public PodInfoFaultEvent getFaultEvent() {
return faultEvent; return faultEvent;
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }

View file

@ -13,4 +13,9 @@ public class PodReturnedErrorResponseException extends OmnipodException {
public ErrorResponse getErrorResponse() { public ErrorResponse getErrorResponse() {
return errorResponse; return errorResponse;
} }
@Override
public boolean isCertainFailure() {
return true;
}
} }