aboutsummaryrefslogtreecommitdiff
path: root/Command/AddUrl.hs
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 /Command/AddUrl.hs
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 'Command/AddUrl.hs')
-rw-r--r--Command/AddUrl.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs
index 80f3582ed..e32ceb568 100644
--- a/Command/AddUrl.hs
+++ b/Command/AddUrl.hs
@@ -133,7 +133,7 @@ checkUrl r o u = do
let f' = adjustFile o (deffile </> fromSafeFilePath f)
void $ commandAction $
startRemote r (relaxedOption o) f' u' sz
- | otherwise = error $ unwords
+ | otherwise = giveup $ unwords
[ "That url contains multiple files according to the"
, Remote.name r
, " remote; cannot add it to a single file."
@@ -182,7 +182,7 @@ startWeb :: AddUrlOptions -> String -> CommandStart
startWeb o s = go $ fromMaybe bad $ parseURI urlstring
where
(urlstring, downloader) = getDownloader s
- bad = fromMaybe (error $ "bad url " ++ urlstring) $
+ bad = fromMaybe (giveup $ "bad url " ++ urlstring) $
Url.parseURIRelaxed $ urlstring
go url = case downloader of
QuviDownloader -> usequvi
@@ -208,7 +208,7 @@ startWeb o s = go $ fromMaybe bad $ parseURI urlstring
)
showStart "addurl" file
next $ performWeb (relaxedOption o) urlstring file urlinfo
- badquvi = error $ "quvi does not know how to download url " ++ urlstring
+ badquvi = giveup $ "quvi does not know how to download url " ++ urlstring
usequvi = do
page <- fromMaybe badquvi
<$> withQuviOptions Quvi.forceQuery [Quvi.quiet, Quvi.httponly] urlstring
@@ -372,7 +372,7 @@ url2file url pathdepth pathmax = case pathdepth of
| depth >= length urlbits -> frombits id
| depth > 0 -> frombits $ drop depth
| depth < 0 -> frombits $ reverse . take (negate depth) . reverse
- | otherwise -> error "bad --pathdepth"
+ | otherwise -> giveup "bad --pathdepth"
where
fullurl = concat
[ maybe "" uriRegName (uriAuthority url)
@@ -385,7 +385,7 @@ url2file url pathdepth pathmax = case pathdepth of
urlString2file :: URLString -> Maybe Int -> Int -> FilePath
urlString2file s pathdepth pathmax = case Url.parseURIRelaxed s of
- Nothing -> error $ "bad uri " ++ s
+ Nothing -> giveup $ "bad uri " ++ s
Just u -> url2file u pathdepth pathmax
adjustFile :: AddUrlOptions -> FilePath -> FilePath