From b52c8f667953c9f40428576b0c2e4bf06e9553aa Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Mon, 25 Mar 2024 10:36:57 +0100 Subject: [PATCH] Wrap in try catch --- .../debug/ClientConfigurationAdapter.scala | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala index 8e69e473dc2..caa77b4b87e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala @@ -50,16 +50,20 @@ private[debug] final case class ClientConfigurationAdapter( */ def adaptStackTraceResponse(result: JsonObject): JsonObject = { if (clientId.contains("vscode")) { - // For VSCode only, we hack the json result of the stack trace response - // to replace all occurrences of 'subtle' by 'deemphasize'. - val frames = result.get("stackFrames").getAsJsonArray() - for (i <- 0.until(frames.size)) { - val frame = frames.get(i).getAsJsonObject() - val presentationHint = Option(frame.get("presentationHint")) - .map(_.getAsJsonPrimitive.getAsString) - if (presentationHint.contains("subtle")) { - frame.add("presentationHint", new JsonPrimitive("deemphasize")) + try { + // For VSCode only, we hack the json result of the stack trace response + // to replace all occurrences of 'subtle' by 'deemphasize'. + val frames = result.get("stackFrames").getAsJsonArray() + for (i <- 0.until(frames.size)) { + val frame = frames.get(i).getAsJsonObject() + val presentationHint = Option(frame.get("presentationHint")) + .map(_.getAsJsonPrimitive.getAsString) + if (presentationHint.contains("subtle")) { + frame.add("presentationHint", new JsonPrimitive("deemphasize")) + } } + } catch { + case _: IllegalStateException => () } } result