Skip to content

Commit a595fe0

Browse files
committed
Refactor tolerance handling in TouchChemControllerCommands to ensure data integrity by checking for the existence of 'data.ph' and 'data.orp' before accessing their properties. This prevents potential runtime errors when tolerances are not defined. #1027 #1027
1 parent 8ebad76 commit a595fe0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

controller/boards/EasyTouchBoard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,8 +3040,8 @@ class TouchChemControllerCommands extends ChemControllerCommands {
30403040
}
30413041
if (isNaN(pHSetpoint) || pHSetpoint > type.ph.max || pHSetpoint < type.ph.min) return Promise.reject(new InvalidEquipmentDataError(`Invalid pH setpoint`, 'ph.setpoint', pHSetpoint));
30423042
if (isNaN(orpSetpoint) || orpSetpoint > type.orp.max || orpSetpoint < type.orp.min) return Promise.reject(new InvalidEquipmentDataError(`Invalid orp setpoint`, 'orp.setpoint', orpSetpoint));
3043-
let phTolerance = typeof data.ph.tolerance !== 'undefined' ? data.ph.tolerance : chem.ph.tolerance;
3044-
let orpTolerance = typeof data.orp.tolerance !== 'undefined' ? data.orp.tolerance : chem.orp.tolerance;
3043+
let phTolerance = (data.ph && typeof data.ph.tolerance !== 'undefined') ? data.ph.tolerance : chem.ph.tolerance;
3044+
let orpTolerance = (data.orp && typeof data.orp.tolerance !== 'undefined') ? data.orp.tolerance : chem.orp.tolerance;
30453045
if (typeof data.ph.tolerance !== 'undefined') {
30463046
if (typeof data.ph.tolerance.enabled !== 'undefined') phTolerance.enabled = utils.makeBool(data.ph.tolerance.enabled);
30473047
if (typeof data.ph.tolerance.low !== 'undefined') phTolerance.low = parseFloat(data.ph.tolerance.low);

0 commit comments

Comments
 (0)