mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[hal] Use last error reporting instead of PARAMETER_OUT_OF_RANGE (#3328)
Makes the error messages much more specific to each error.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "ConstantsInternal.h"
|
||||
#include "DigitalInternal.h"
|
||||
#include "HALInitializer.h"
|
||||
#include "HALInternal.h"
|
||||
#include "PortsInternal.h"
|
||||
#include "hal/AddressableLEDTypes.h"
|
||||
#include "hal/ChipObject.h"
|
||||
@@ -142,8 +143,11 @@ void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
|
||||
return;
|
||||
}
|
||||
|
||||
if (length > HAL_kAddressableLEDMaxLength) {
|
||||
if (length > HAL_kAddressableLEDMaxLength || length < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(status, "LED length must be less than or equal to " +
|
||||
wpi::Twine(HAL_kAddressableLEDMaxLength) +
|
||||
". " + wpi::Twine(length) + " was requested");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,8 +177,11 @@ void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
|
||||
return;
|
||||
}
|
||||
|
||||
if (length > led->stringLength) {
|
||||
if (length > led->stringLength || length < 0) {
|
||||
*status = PARAMETER_OUT_OF_RANGE;
|
||||
hal::SetLastError(status, "Data length must be less than or equal to " +
|
||||
wpi::Twine(led->stringLength) + ". " +
|
||||
wpi::Twine(length) + " was requested");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user