Fix undefined error for Turtle update

Even though the error occurs not very frequent, we want to resolve it. Sentry identified that the former error still occurs and we try once more to fix it.

Fixes CODEOCEAN-JH
This commit is contained in:
Sebastian Serth
2023-03-14 19:31:51 +01:00
parent d015e1536c
commit bb9e0d4825

View File

@ -91,6 +91,12 @@ Turtle.prototype.update = function () {
const dx = canvas.width / (2 * devicePixelRatio);
const dy = canvas.height / (2 * devicePixelRatio);
for (let item of this.items) {
// This should not happen, but it does for some unknown reason.
// Therefore, we just check for the potential error and break.
if (item === undefined || item === null) {
break;
}
c = item.coords;
switch (item.type) {
case 'line':