From bb9e0d48255bde25a7033e152dcc1c24adee7d18 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 14 Mar 2023 19:31:51 +0100 Subject: [PATCH] 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 --- app/assets/javascripts/turtle.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/javascripts/turtle.js b/app/assets/javascripts/turtle.js index c570dd13..d475eac9 100644 --- a/app/assets/javascripts/turtle.js +++ b/app/assets/javascripts/turtle.js @@ -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':