(* rpmdepsize - visualize the size of RPM dependencies * (C) Copyright 2009 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Written by Richard W.M. Jones * * Some universal code to handle exceptions. *) open Printf open Unix let () = let display_error title msg = let icon = GMisc.image () in icon#set_stock `DIALOG_ERROR; icon#set_icon_size `DIALOG; GToolbox.message_box ~title ~icon msg in let unexpected exn_name err = sprintf "Unexpected %s exception:\n\n%s\n\nPlease report this error to the software authors" exn_name err in GtkSignal.user_handler := function | Unix_error (err, syscall, filename) -> display_error "Filesystem error" (syscall ^ ": " ^ filename ^ ": " ^ error_message err) | Sys_error err -> display_error "System error" err | Invalid_argument err -> display_error "Invalid argument" (unexpected "Invalid_argument" err) | Failure err -> display_error "Internal error" (unexpected "Failure" err) | Assert_failure (err, start, end_) -> display_error "Assertion failure" (unexpected "Assertion_failure" (err ^ " (" ^ string_of_int start ^ ", " ^ string_of_int end_)) | Glib.GError err -> display_error "Gtk Internal error" (unexpected "GLib.GError" err) | exn -> display_error "Error" (unexpected "internal" (Printexc.to_string exn))