Skip to content

Commit d7b2ca3

Browse files
committedNov 21, 2014
When net_tap driver can't initialize, emit human error
Fixes #164.
1 parent 97833d7 commit d7b2ca3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
 

‎lib/mirage.ml

+13-2
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,8 @@ module STACKV4_direct = struct
12251225
@ Impl.libraries t.network
12261226
@ Impl.libraries t.random
12271227

1228+
let tuntap_help = "Is tun/tap enabled and have you permissions?\\n\\n"
1229+
12281230
let configure t =
12291231
let name = name t in
12301232
Impl.configure t.clock;
@@ -1254,8 +1256,17 @@ module STACKV4_direct = struct
12541256
(driver_initialisation_error (Impl.name t.console));
12551257
append_main " | `Ok console ->";
12561258
append_main " %s () >>= function" (Impl.name t.network);
1257-
append_main " | `Error _ -> %s"
1258-
(driver_initialisation_error (Impl.name t.network));
1259+
append_main " | `Error e ->";
1260+
let name = Impl.name t.network in begin
1261+
append_main " fail (Failure begin match e with";
1262+
append_main " %s -> \"\\n\\n\"^%S^\": \"^msg^\"\\n%s\""
1263+
"| `Unknown msg" name tuntap_help;
1264+
append_main " %s -> \"\\n\\n\"^%S^\": operation unimplemented\\n\\n\""
1265+
"| `Unimplemented" name;
1266+
append_main " %s -> \"\\n\\n\"^%S^\": disconnected\\n\\n\""
1267+
"| `Disconnected" name;
1268+
append_main " end)";
1269+
end;
12591270
append_main " | `Ok interface ->";
12601271
append_main " let config = {";
12611272
append_main " V1_LWT.name = %S;" name;

0 commit comments

Comments
 (0)