From 5ff9830629453beb4b5e88ebaa1df2cf7b073185 Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Thu, 21 Sep 2023 12:23:57 -0500 Subject: [PATCH] fix: gracefully handle injected attributes (#235) Fixes #234 --- lib/next_ls/runtime/sidecar.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/next_ls/runtime/sidecar.ex b/lib/next_ls/runtime/sidecar.ex index 7d52da65..a2b2e4b3 100644 --- a/lib/next_ls/runtime/sidecar.ex +++ b/lib/next_ls/runtime/sidecar.ex @@ -60,8 +60,12 @@ defmodule NextLS.Runtime.Sidecar do end def handle_info({{:tracer, :reference, :attribute}, payload}, state) do - name = Attributes.get_attribute_reference_name(payload.file, payload.meta[:line], payload.meta[:column]) - if name, do: DB.insert_reference(state.db, %{payload | identifier: name}) + try do + name = Attributes.get_attribute_reference_name(payload.file, payload.meta[:line], payload.meta[:column]) + if name, do: DB.insert_reference(state.db, %{payload | identifier: name}) + rescue + _ -> :ok + end {:noreply, state} end