darcs

Issue 822 improve 'host not found' error message

Title improve 'host not found' error message
Priority feature Status resolved
Milestone 2.10.0 Resolved in 2.10.0
Superseder Nosy List dmitry.kurochkin, jaredj, kowey, markstos, thorkilnaur, tommy
Assigned To
Topics HTTP, ProbablyEasy, SSH, UI

Created on 2008-04-29.21:37:55 by dagit, last changed 2015-02-05.16:57:47 by bf.

Messages
msg4387 (view) Author: dagit Date: 2008-04-29.21:37:54
I think the following error message is a bit misleading:

$ darcs pull me@typo:valid_path

darcs failed:  Not a repository: me@typo:valid_path ((scp) failed to fetch:
me@typo:valid_path/_darcs/inventory)


We should change the error message to be more precise in this case.  Everything
was good except the host name, so it would have been nice to see a "host not
found" or similar.
msg4402 (view) Author: dagit Date: 2008-04-30.14:52:06
The error message with get seems to be similarly imprecise:
$ darcs get http://blah

darcs failed:  Not a repository: http://blah (failed to fetch:
http://blah/_darcs/inventory ExitFailure 1)
msg5460 (view) Author: markstos Date: 2008-08-13.02:11:29
I agree that a more specific error out to be available and we ought be able to
bubble that up to the user. For example, if I 'scp' to a typo'ed domain, I get
this back:

ssh: typoed-domain.com: Name or service not known

It seems to me that we ought to be able to capture something like that and pass
it back through to the user.
msg17886 (view) Author: netogallo Date: 2014-12-09.15:28:15
I took a look at this issue. There are a number of things to consider:

1) scp returns a -1 exit code when host is not found. Since -1 is
returned for general failures, the only way to know what really happened
is inspecting the output.

2) In the file Darcs/Repository/Format.hs:113, all a catchall exception
guard is used and the result is set to an empty Bytestring if failed.
Then a generic error message is given.

To solve (1) we either use an ssh library for Haskell or we read the
output of the ssh command. If you don't mind the extra dependency,
http://hackage.haskell.org/package/knob, seems worth trying to dump the
output directly to memory. Otherwise a temporary file handle has to be used.
To solve (2) We can throw an ExecException with the error message from
scp on failure and catch that exception in Format.hs for a better
message. Or change the function fetchFilePS to return an either type
which is a more Haskell way of doing it.

I am happy to work on this issue by reading the output from ssh and
changing the type of fetchFilePS but since I have not contributed to
Darcs, would like to know if my approach is reasonable.
msg17888 (view) Author: ganesh Date: 2014-12-09.20:35:29
Thanks a lot for volunteering - anything you can do would be very 
welcome. I think your approach sounds just right.

I'd go with the Either type rather than an exception, as you say 
it's the more Haskell way.

Is it really necessary to use a separate package to hook up the 
output from one command - can't we instead get the Handles from 
running the process with e.g. runInteractiveProcess? It's not 
something I'm particularly familiar with though so I may well be 
missing something.

If it is necessary, it's fine to use knob. There's also bytestring-
handle which I wrote a while ago because I thought it would be 
needed to solve some encoding issues in darcs, but in the end it 
didn't work out, so the package isn't necessarily well tested etc.
msg17891 (view) Author: netogallo Date: 2014-12-10.09:52:07
Thanks for your feedback. I will work on it. I will try asking what is
the best way to get the output of a process w/o using temporary files or
extra packages. I hope I can get a good solution.
msg17920 (view) Author: bf Date: 2014-12-30.13:17:55
The canonical package that everyone uses for this kind of stuff is
http://hackage.haskell.org/package/process
msg18029 (view) Author: bf Date: 2015-02-05.16:57:46
Resolved by Patch1246
History
Date User Action Args
2008-04-29 21:37:55dagitcreate
2008-04-30 14:52:07dagitsetstatus: unread -> unknown
nosy: tommy, beschmi, dagit
messages: + msg4402
title: misleading error message with pull -> misleading error message with bad hostnames
2008-04-30 19:29:48koweysettopic: + UI
nosy: tommy, beschmi, dagit
title: misleading error message with bad hostnames -> wish: 'host not found' error message
2008-08-13 02:11:32markstossetstatus: unknown -> deferred
nosy: + kowey, markstos
messages: + msg5460
title: wish: 'host not found' error message -> wish: 'host not found' error message could be improved
2009-08-06 21:03:34adminsetnosy: + dmitry.kurochkin, simon, thorkilnaur, - beschmi
2009-08-11 00:11:58adminsetnosy: - dagit
2009-08-25 18:10:27adminsetnosy: + darcs-devel, - simon
2009-08-27 14:02:47adminsetnosy: tommy, kowey, markstos, darcs-devel, thorkilnaur, dmitry.kurochkin
2009-09-04 10:57:44koweysetstatus: deferred -> needs-implementation
nosy: tommy, kowey, markstos, darcs-devel, thorkilnaur, dmitry.kurochkin
topic: + SSH, HTTP
2010-09-09 18:59:11koweysetpriority: wishlist -> feature
nosy: + jaredj, - darcs-devel
topic: + ProbablyEasy
title: wish: 'host not found' error message could be improved -> improve 'host not found' error message
2014-12-09 15:28:17netogallosetmessages: + msg17886
2014-12-09 20:35:31ganeshsetmessages: + msg17888
2014-12-10 09:52:08netogallosetmessages: + msg17891
2014-12-30 13:17:56bfsetmessages: + msg17920
2015-02-05 16:37:11bfsetstatus: needs-implementation -> has-patch
milestone: 2.10.0
2015-02-05 16:57:47bfsetstatus: has-patch -> resolved
messages: + msg18029
resolvedin: 2.10.0
2015-02-18 21:35:13ghlinkissue2113 superseder