Throw UncleanStatusException rather then RuntimeException (#1114)

This commit is contained in:
Thad House
2018-05-30 23:36:40 -07:00
committed by Peter Johnson
parent 85fe722f4c
commit d9971a705a
3 changed files with 18 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.hal.SolenoidJNI;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.util.UncleanStatusException;
/**
* DoubleSolenoid class for running 2 channels of high voltage Digital Output on the PCM.
@@ -64,7 +65,7 @@ public class DoubleSolenoid extends SolenoidBase {
try {
portHandle = HAL.getPortWithModule((byte) m_moduleNumber, (byte) reverseChannel);
m_reverseHandle = SolenoidJNI.initializeSolenoidPort(portHandle);
} catch (RuntimeException ex) {
} catch (UncleanStatusException ex) {
// free the forward handle on exception, then rethrow
SolenoidJNI.freeSolenoidPort(m_forwardHandle);
m_forwardHandle = 0;

View File

@@ -14,6 +14,7 @@ import edu.wpi.first.wpilibj.hal.FRCNetComm.tResourceType;
import edu.wpi.first.wpilibj.hal.HAL;
import edu.wpi.first.wpilibj.hal.RelayJNI;
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilder;
import edu.wpi.first.wpilibj.util.UncleanStatusException;
import static java.util.Objects.requireNonNull;
@@ -149,12 +150,12 @@ public class Relay extends SendableBase implements MotorSafety {
private void freeRelay() {
try {
RelayJNI.setRelay(m_forwardHandle, false);
} catch (RuntimeException ex) {
} catch (UncleanStatusException ex) {
// do nothing. Ignore
}
try {
RelayJNI.setRelay(m_reverseHandle, false);
} catch (RuntimeException ex) {
} catch (UncleanStatusException ex) {
// do nothing. Ignore
}