diff options
author | G.raud <graud@gmx.com> | 2018-01-17 12:47:50 +0100 |
---|---|---|
committer | G.raud <graud@gmx.com> | 2018-01-17 14:24:49 +0100 |
commit | befe56c79a14167148d8724641baf6b2919ba2dc (patch) | |
tree | d2fab3ed81721ec0fbb0cb10e2c05fc08af097b5 /src | |
parent | 23e7ea9509fa5c678db0de4cd87772ff06d83180 (diff) | |
download | unison-befe56c79a14167148d8724641baf6b2919ba2dc.zip unison-befe56c79a14167148d8724641baf6b2919ba2dc.tar.gz unison-befe56c79a14167148d8724641baf6b2919ba2dc.tar.bz2 |
Uitext.selectAction: print error if exception raised while reading stdin
This change prints an error message in the case (amongst others) of the
rare condition that Unison can write to the terminal but fails to read
from it.
The exceptions are raised only inside Uitext.getInput which is called
only by Uitext.selectAction. So catch the exceptions there to print a
message then re-raise them (for now).
Diffstat (limited to 'src')
-rw-r--r-- | src/uitext.ml | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/uitext.ml b/src/uitext.ml index 3706923..7a0225b 100644 --- a/src/uitext.ml +++ b/src/uitext.ml @@ -177,7 +177,17 @@ let rec selectAction batch actions tryagain = doAction (match batch with None -> summarizeChoices(); - getInput () + begin try getInput () with e -> + (* Simply print a slightly more informative message than the exception + * itself (e.g. "Uncaught unix error: read failed: Resource temporarily + * unavailable" or "Uncaught exception End_of_file") and make sure the + * error messages start on their own lines. *) + Util.msg "\nError while reading from the standard input\n"; + (* FIX: Unison should or may have a better or standard way to treat + * such exceptions; maybe a cleanup (e.g. restoreTerminal()) should be + * made at some point. *) + raise e + end | Some i -> i) let alwaysDisplayErrors prefix l = |