summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-11-15 21:29:54 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-11-15 21:29:54 -0400
commit381766efcdddb4c8706408a90c515470a6aa43a7 (patch)
treedda693b36724839ff2daff0e0766b7bdd883ea2c /Annex
parent27fafd61c39f8436e19e8fd449b5851ead10bbd1 (diff)
Avoid backtraces on expected failures when built with ghc 8; only use backtraces for unexpected errors.
ghc 8 added backtraces on uncaught errors. This is great, but git-annex was using error in many places for a error message targeted at the user, in some known problem case. A backtrace only confuses such a message, so omit it. Notably, commands like git annex drop that failed due to eg, numcopies, used to use error, so had a backtrace. This commit was sponsored by Ethan Aubin.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/AdjustedBranch.hs6
-rw-r--r--Annex/Branch.hs4
-rw-r--r--Annex/Content.hs4
-rw-r--r--Annex/FileMatcher.hs2
-rw-r--r--Annex/Init.hs2
-rw-r--r--Annex/View.hs4
6 files changed, 11 insertions, 11 deletions
diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs
index 4caf637c7..72c07a5bc 100644
--- a/Annex/AdjustedBranch.hs
+++ b/Annex/AdjustedBranch.hs
@@ -596,7 +596,7 @@ checkAdjustedClone = ifM isBareRepo
aps <- fmap commitParent <$> findAdjustingCommit (AdjBranch currbranch)
case aps of
Just [p] -> setBasisBranch basis p
- _ -> error $ "Unable to clean up from clone of adjusted branch; perhaps you should check out " ++ Git.Ref.describe origbranch
+ _ -> giveup $ "Unable to clean up from clone of adjusted branch; perhaps you should check out " ++ Git.Ref.describe origbranch
ifM versionSupportsUnlockedPointers
( return InAdjustedClone
, return NeedUpgradeForAdjustedClone
@@ -610,6 +610,6 @@ isGitVersionSupported = not <$> Git.Version.older "2.2.0"
checkVersionSupported :: Annex ()
checkVersionSupported = do
unlessM versionSupportsAdjustedBranch $
- error "Adjusted branches are only supported in v6 or newer repositories."
+ giveup "Adjusted branches are only supported in v6 or newer repositories."
unlessM (liftIO isGitVersionSupported) $
- error "Your version of git is too old; upgrade it to 2.2.0 or newer to use adjusted branches."
+ giveup "Your version of git is too old; upgrade it to 2.2.0 or newer to use adjusted branches."
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index a426c76d8..9663311d5 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -225,7 +225,7 @@ getHistorical date file =
-- This check avoids some ugly error messages when the reflog
-- is empty.
ifM (null <$> inRepo (Git.RefLog.get' [Param (fromRef fullname), Param "-n1"]))
- ( error ("No reflog for " ++ fromRef fullname)
+ ( giveup ("No reflog for " ++ fromRef fullname)
, getRef (Git.Ref.dateRef fullname date) file
)
@@ -574,7 +574,7 @@ checkBranchDifferences ref = do
<$> catFile ref differenceLog
mydiffs <- annexDifferences <$> Annex.getGitConfig
when (theirdiffs /= mydiffs) $
- error "Remote repository is tuned in incompatable way; cannot be merged with local repository."
+ giveup "Remote repository is tuned in incompatable way; cannot be merged with local repository."
ignoreRefs :: [Git.Sha] -> Annex ()
ignoreRefs rs = do
diff --git a/Annex/Content.hs b/Annex/Content.hs
index cb96a0068..e879e4eeb 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -268,8 +268,8 @@ lockContentUsing locker key a = do
(unlock lockfile)
(const a)
where
- alreadylocked = error "content is locked"
- failedtolock e = error $ "failed to lock content: " ++ show e
+ alreadylocked = giveup "content is locked"
+ failedtolock e = giveup $ "failed to lock content: " ++ show e
lock contentfile lockfile =
(maybe alreadylocked return
diff --git a/Annex/FileMatcher.hs b/Annex/FileMatcher.hs
index fa46e64b1..654c5a960 100644
--- a/Annex/FileMatcher.hs
+++ b/Annex/FileMatcher.hs
@@ -165,7 +165,7 @@ largeFilesMatcher = go =<< annexLargeFiles <$> Annex.getGitConfig
mkmatcher expr = do
parser <- mkLargeFilesParser
either badexpr return $ parsedToMatcher $ parser expr
- badexpr e = error $ "bad annex.largefiles configuration: " ++ e
+ badexpr e = giveup $ "bad annex.largefiles configuration: " ++ e
simply :: MatchFiles Annex -> ParseResult
simply = Right . Operation
diff --git a/Annex/Init.hs b/Annex/Init.hs
index 5aff4cf39..8a208fe2b 100644
--- a/Annex/Init.hs
+++ b/Annex/Init.hs
@@ -129,7 +129,7 @@ ensureInitialized = getVersion >>= maybe needsinit checkUpgrade
where
needsinit = ifM Annex.Branch.hasSibling
( initialize Nothing Nothing
- , error "First run: git-annex init"
+ , giveup "First run: git-annex init"
)
{- Checks if a repository is initialized. Does not check version for ugrade. -}
diff --git a/Annex/View.hs b/Annex/View.hs
index 7d2b43e60..d865c8f78 100644
--- a/Annex/View.hs
+++ b/Annex/View.hs
@@ -110,7 +110,7 @@ refineView origview = checksize . calc Unchanged origview
in (view', Narrowing)
checksize r@(v, _)
- | viewTooLarge v = error $ "View is too large (" ++ show (visibleViewSize v) ++ " levels of subdirectories)"
+ | viewTooLarge v = giveup $ "View is too large (" ++ show (visibleViewSize v) ++ " levels of subdirectories)"
| otherwise = r
updateViewComponent :: ViewComponent -> MetaField -> ViewFilter -> Writer [ViewChange] ViewComponent
@@ -424,4 +424,4 @@ genViewBranch view = withViewIndex $ do
return branch
withCurrentView :: (View -> Annex a) -> Annex a
-withCurrentView a = maybe (error "Not in a view.") a =<< currentView
+withCurrentView a = maybe (giveup "Not in a view.") a =<< currentView