mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Throw UncleanStatusException rather then RuntimeException (#1114)
This commit is contained in:
committed by
Peter Johnson
parent
85fe722f4c
commit
d9971a705a
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user