[Pkg-libvirt-commits] [libguestfs] 07/266: sysprep: Standard exception handling, taken from virt-builder & virt-v2v.

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:30 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit 9d8ede1ae4b8b926a00c16d0f6ba52d8a6defbd7
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Thu Jul 10 17:32:39 2014 +0100

    sysprep: Standard exception handling, taken from virt-builder & virt-v2v.
---
 sysprep/main.ml | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/sysprep/main.ml b/sysprep/main.ml
index ef5d8c9..a3900a5 100644
--- a/sysprep/main.ml
+++ b/sysprep/main.ml
@@ -286,21 +286,34 @@ let do_sysprep () =
 let () =
   (try do_sysprep ()
    with
+   | Unix.Unix_error (code, fname, "") -> (* from a syscall *)
+     eprintf (f_"%s: error: %s: %s\n") prog fname (Unix.error_message code);
+     exit 1
+   | Unix.Unix_error (code, fname, param) -> (* from a syscall *)
+     eprintf (f_"%s: error: %s: %s: %s\n") prog fname (Unix.error_message code)
+       param;
+     exit 1
+   | Sys_error msg ->                   (* from a syscall *)
+     eprintf (f_"%s: error: %s\n") prog msg;
+     exit 1
+   | G.Error msg ->                     (* from libguestfs *)
+     eprintf (f_"%s: libguestfs error: %s\n") prog msg;
+     exit 1
    | Failure msg ->                     (* from failwith/failwithf *)
-     eprintf (f_"sysprep operation failed: %s\n") msg;
+     eprintf (f_"%s: failure: %s\n") prog msg;
      exit 1
    | Invalid_argument msg ->            (* probably should never happen *)
-     eprintf (f_"sysprep operation failed: internal error: invalid argument: %s\n") msg;
+     eprintf (f_"%s: internal error: invalid argument: %s\n") prog msg;
      exit 1
    | Assert_failure (file, line, char) -> (* should never happen *)
-     eprintf (f_"sysprep operation failed: internal error: assertion failed at %s, line %d, char %d\n") file line char;
+     eprintf (f_"%s: internal error: assertion failed at %s, line %d, char %d\n")
+       prog file line char;
      exit 1
    | Not_found ->                       (* should never happen *)
-     eprintf (f_"sysprep operation failed: internal error: Not_found exception was thrown\n");
+     eprintf (f_"%s: internal error: Not_found exception was thrown\n") prog;
      exit 1
    | exn ->
-     eprintf (f_"sysprep operation failed: exception: %s\n")
-       (Printexc.to_string exn);
+     eprintf (f_"%s: exception: %s\n") prog (Printexc.to_string exn);
      exit 1
   );
   g#shutdown ();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list