summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-15 19:17:07 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-15 19:17:07 -0400
commit5c5ff2cb78230ca6311d49dc2573579af49d8c37 (patch)
treea06acc0ea97ff67c6ef15e77db2080a3f80ec051
parent80a0be5116ada2c718fa6db0a90100d24660beec (diff)
better error message
-rw-r--r--git-annex-shell.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/git-annex-shell.hs b/git-annex-shell.hs
index 57f6b2916..658eddd77 100644
--- a/git-annex-shell.hs
+++ b/git-annex-shell.hs
@@ -40,14 +40,17 @@ cmds = map adddirparam $ cmds_readonly ++ cmds_notreadonly
options :: [OptDescr (Annex ())]
options = commonOptions ++
- [ Option [] ["uuid"] (ReqArg check paramUUID) "repository uuid"
+ [ Option [] ["uuid"] (ReqArg checkuuid paramUUID) "repository uuid"
]
where
- check expected = do
- u <- getUUID
- when (u /= toUUID expected) $ error $
- "expected repository UUID " ++ expected
- ++ " but found UUID " ++ fromUUID u
+ checkuuid expected = getUUID >>= check
+ where
+ check u | u == toUUID expected = return ()
+ check NoUUID = unexpected "uninitialized repository"
+ check u = unexpected $ "UUID " ++ fromUUID u
+ unexpected s = error $
+ "expected repository UUID " ++
+ expected ++ " but found " ++ s
header :: String
header = "Usage: git-annex-shell [-c] command [parameters ...] [option ..]"