Skip to content

Commit

Permalink
Don't pass error messages generated in loadURI down the line as they …
Browse files Browse the repository at this point in the history
…already get printed out eagerly
  • Loading branch information
Russoul committed Nov 30, 2024
1 parent 3f65f16 commit e1076ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Server/ProcessMessage.idr
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ loadURI : Ref LSPConf LSPConfiguration
=> Ref Syn SyntaxInfo
=> Ref MD Metadata
=> Ref ROpts REPLOpts
=> InitializeParams -> URI -> Maybe Int -> Core (Either String ())
=> InitializeParams -> URI -> Maybe Int -> Core (Either () ())
loadURI conf uri version = do
logI Channel "Loading file \{show uri}"
defs <- get Ctxt
Expand All @@ -220,7 +220,7 @@ loadURI conf uri version = do
let Just (startFolder, startFile) = splitParent fpath
| Nothing => do let msg = "Cannot find the parent folder for \{show uri}"
logE Server msg
pure $ Left msg
pure $ Left ()
-- Save CWD
cwd <- getWorkingDir
Right packageFilePath <- catch
Expand All @@ -233,19 +233,19 @@ loadURI conf uri version = do
(pure . Left)
| Left err => do let msg = "Cannot load .ipkg file: \{show err}"
logE Channel msg
pure $ Left msg
pure $ Left ()
logI Channel ".ipkg file configured to: \{packageFilePath}"
Right packageFileSource <- coreLift $ File.ReadWrite.readFile packageFilePath
| Left err => do let msg = "Cannot read .ipkg at \{packageFilePath} with CWD \{!getWorkingDir}"
logE Channel msg
pure $ Left msg
pure $ Left ()
logI Channel ".ipkg file read!"
let Just (packageFileDir, packageFileName) = splitParent packageFilePath
| _ => throw $ InternalError "Tried to split empty string"
let True = isSuffixOf ".ipkg" packageFileName
| _ => do let msg = "Packages must have an '.ipkg' extension: \{packageFilePath}"
logE Channel msg
pure $ Left msg
pure $ Left ()
-- The CWD should be set to that of the .ipkg file
setWorkingDir packageFileDir
-- Using local packageFileName as we are now in the directory containing that file
Expand Down Expand Up @@ -311,7 +311,7 @@ loadIfNeeded : Ref LSPConf LSPConfiguration
=> Ref Syn SyntaxInfo
=> Ref MD Metadata
=> Ref ROpts REPLOpts
=> InitializeParams -> URI -> Maybe Int -> Core (Either String ())
=> InitializeParams -> URI -> Maybe Int -> Core (Either () ())
loadIfNeeded conf uri version = do
Just (oldUri, oldVersion) <- gets LSPConf openFile
| Nothing => loadURI conf uri version
Expand All @@ -332,7 +332,7 @@ withURI conf uri version d k = do
case !(loadIfNeeded conf uri version) of
Right () => k
Left err => do
pure $ Left (MkResponseError (Custom 3) err JNull)
pure $ Left (MkResponseError (Custom 3) "Loading \{show uri} failed (see the logs for more info)" JNull)

||| Guard for requests that requires a successful initialization before being allowed.
whenInitializedRequest : Ref LSPConf LSPConfiguration => (InitializeParams -> Core (Either ResponseError a)) -> Core (Either ResponseError a)
Expand Down

0 comments on commit e1076ef

Please sign in to comment.