Protect against out of bounds array condition

This commit is contained in:
D. Berge
2025-07-28 10:10:05 +02:00
parent 31ac8d3c01
commit 89c565a0f5

View File

@@ -124,8 +124,12 @@ class SequenceDataLayer extends CompositeLayer {
}; };
SequenceDataLayer.layerName = "SequenceDataLayer"; SequenceDataLayer.layerName = "SequenceDataLayer";
SequenceDataLayer.tooltip = ({index, sourceLayer}) => { SequenceDataLayer.tooltip = ({index, sourceLayer}) => {
try {
if (index >= 0) { if (index >= 0) {
const p = sourceLayer?.props?.data; const p = sourceLayer?.props?.data;
if (index >= p.length) {
console.log("Index out of bounds");
}
// console.log("P", p); // console.log("P", p);
if (p.type == MSGTYPE.PREPLOT_RAWERROR_OPT) { if (p.type == MSGTYPE.PREPLOT_RAWERROR_OPT) {
@@ -149,6 +153,10 @@ SequenceDataLayer.tooltip = ({index, sourceLayer}) => {
return {html}; return {html};
} }
} }
} catch (err) {
console.error(err.message);
console.log(index, sourceLayer);
}
}; };