mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
trap the invalid array index
This commit is contained in:
parent
ba31af7849
commit
2f8f147517
|
@ -174,8 +174,11 @@ class Property(Logging):
|
|||
raise ExecutionError(errorClass='property', errorCode='propertyIsNotAnArray')
|
||||
|
||||
if value is not None:
|
||||
# dive in, the water's fine
|
||||
value = value[arrayIndex]
|
||||
try:
|
||||
# dive in, the water's fine
|
||||
value = value[arrayIndex]
|
||||
except IndexError:
|
||||
raise ExecutionError(errorClass='property', errorCode='invalidArrayIndex')
|
||||
|
||||
# all set
|
||||
return value
|
||||
|
@ -228,7 +231,10 @@ class Property(Logging):
|
|||
|
||||
# seems to be OK, let the array object take over
|
||||
if _debug: Property._debug(" - forwarding to array")
|
||||
arry[arrayIndex] = value
|
||||
try:
|
||||
arry[arrayIndex] = value
|
||||
except IndexError:
|
||||
raise ExecutionError(errorClass='property', errorCode='invalidArrayIndex')
|
||||
|
||||
# check for monitors, call each one with the old and new value
|
||||
if is_monitored:
|
||||
|
|
|
@ -175,8 +175,11 @@ class Property:
|
|||
raise ExecutionError(errorClass='property', errorCode='propertyIsNotAnArray')
|
||||
|
||||
if value is not None:
|
||||
# dive in, the water's fine
|
||||
value = value[arrayIndex]
|
||||
try:
|
||||
# dive in, the water's fine
|
||||
value = value[arrayIndex]
|
||||
except IndexError:
|
||||
raise ExecutionError(errorClass='property', errorCode='invalidArrayIndex')
|
||||
|
||||
# all set
|
||||
return value
|
||||
|
@ -229,7 +232,10 @@ class Property:
|
|||
|
||||
# seems to be OK, let the array object take over
|
||||
if _debug: Property._debug(" - forwarding to array")
|
||||
arry[arrayIndex] = value
|
||||
try:
|
||||
arry[arrayIndex] = value
|
||||
except IndexError:
|
||||
raise ExecutionError(errorClass='property', errorCode='invalidArrayIndex')
|
||||
|
||||
# check for monitors, call each one with the old and new value
|
||||
if is_monitored:
|
||||
|
|
|
@ -175,8 +175,11 @@ class Property:
|
|||
raise ExecutionError(errorClass='property', errorCode='propertyIsNotAnArray')
|
||||
|
||||
if value is not None:
|
||||
# dive in, the water's fine
|
||||
value = value[arrayIndex]
|
||||
try:
|
||||
# dive in, the water's fine
|
||||
value = value[arrayIndex]
|
||||
except IndexError:
|
||||
raise ExecutionError(errorClass='property', errorCode='invalidArrayIndex')
|
||||
|
||||
# all set
|
||||
return value
|
||||
|
@ -229,7 +232,10 @@ class Property:
|
|||
|
||||
# seems to be OK, let the array object take over
|
||||
if _debug: Property._debug(" - forwarding to array")
|
||||
arry[arrayIndex] = value
|
||||
try:
|
||||
arry[arrayIndex] = value
|
||||
except IndexError:
|
||||
raise ExecutionError(errorClass='property', errorCode='invalidArrayIndex')
|
||||
|
||||
# check for monitors, call each one with the old and new value
|
||||
if is_monitored:
|
||||
|
|
Loading…
Reference in New Issue
Block a user