Skip to content

Commit 754805c

Browse files
committed
Print error when trying to open UI if it's not running
1 parent 35f971c commit 754805c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

unison-cli/src/Unison/Codebase/Editor/HandleInput/UI.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Unison.Cli.Monad qualified as Cli
1616
import Unison.Cli.MonadUtils qualified as Cli
1717
import Unison.Codebase (Codebase)
1818
import Unison.Codebase qualified as Codebase
19+
import Unison.Codebase.Editor.Output (Output (..))
1920
import Unison.Codebase.Path qualified as Path
2021
import Unison.Codebase.ProjectPath qualified as PP
2122
import Unison.Codebase.SqliteCodebase.Conversions qualified as Conversions
@@ -37,8 +38,10 @@ openUI path' = do
3738
Cli.Env {serverBaseUrl} <- ask
3839
defnPath <- Cli.resolvePath' path'
3940
pp <- Cli.getCurrentProjectPath
40-
whenJust serverBaseUrl \url -> do
41-
openUIForProject url pp (defnPath ^. PP.absPath_)
41+
case serverBaseUrl of
42+
Just url -> openUIForProject url pp (defnPath ^. PP.absPath_)
43+
Nothing -> do
44+
Cli.respond UCMServerNotRunning
4245

4346
openUIForProject :: Server.BaseUrl -> PP.ProjectPath -> Path.Absolute -> Cli ()
4447
openUIForProject url pp@(PP.ProjectPath project projectBranch perspective) defnPath = do

unison-cli/src/Unison/Codebase/Editor/Output.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ data Output
465465
| SyncPullError (Sync.SyncError SyncV2.PullError)
466466
| SyncFromCodebaseMissingProjectBranch (ProjectAndBranch ProjectName ProjectBranchName)
467467
| OpenCodebaseError CodebasePath OpenCodebaseError
468+
| UCMServerNotRunning
468469

469470
data MoreEntriesThanShown = MoreEntriesThanShown | AllEntriesShown
470471
deriving (Eq, Show)
@@ -709,6 +710,7 @@ isFailure o = case o of
709710
SyncPullError {} -> True
710711
SyncFromCodebaseMissingProjectBranch {} -> True
711712
OpenCodebaseError {} -> True
713+
UCMServerNotRunning -> True
712714

713715
isNumberedFailure :: NumberedOutput -> Bool
714716
isNumberedFailure = \case

unison-cli/src/Unison/CommandLine/OutputMessages.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,6 +2302,7 @@ notifyUser dir = \case
23022302
"The codebase is at schema version " <> P.shown currentSV <> " but UCM requires schema version " <> P.shown requiredSV <> ".",
23032303
"Please open the other codebase with UCM directly to upgrade it to the latest version, then try again."
23042304
]
2305+
UCMServerNotRunning -> pure (P.wrap "The UCM server is not running.")
23052306

23062307
prettyShareError :: ShareError -> Pretty
23072308
prettyShareError =

0 commit comments

Comments
 (0)