From e786ece8c3f6cca10056c2d5fe4d8d15e4bdd0f8 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Fri, 29 Oct 2021 17:49:42 +0100 Subject: [PATCH] Catch errors when resolving config and creating context --- .../tailwindcss-language-server/src/server.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts index f788bdb..02fa411 100644 --- a/packages/tailwindcss-language-server/src/server.ts +++ b/packages/tailwindcss-language-server/src/server.ts @@ -857,17 +857,22 @@ async function createProjectService( throw new SilentError(`Failed to load config file: ${state.configPath}`) } - state.config = resolveConfig.module(originalConfig) - state.separator = state.config.separator + try { + state.config = resolveConfig.module(originalConfig) + state.separator = state.config.separator - if (state.jit) { - state.jitContext = state.modules.jit.createContext.module(state) - state.jitContext.tailwindConfig.separator = state.config.separator - if (state.jitContext.getClassList) { - state.classList = state.jitContext.getClassList().map((className) => { - return [className, { color: getColor(state, className) }] - }) + if (state.jit) { + state.jitContext = state.modules.jit.createContext.module(state) + state.jitContext.tailwindConfig.separator = state.config.separator + if (state.jitContext.getClassList) { + state.classList = state.jitContext.getClassList().map((className) => { + return [className, { color: getColor(state, className) }] + }) + } } + } catch (error) { + hook.unhook() + throw error } let postcssResult: Result