8f7ce3a87bf6ddf56668a42ab4d1e4ce6333ce43
[guestfs-browser.git] / utils.ml
1 (* Guestfs Browser.
2  * Copyright (C) 2010 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 type ('a, 'b) choice = Either of 'a | Or of 'b
20
21 let verbose = ref true (* XXX settable *)
22
23 let debug fs =
24   let f str = if !verbose then (prerr_string str; prerr_newline ()) in
25   ksprintf f fs
26
27 let failwith fs =
28   let f str =
29     if !verbose then (prerr_string str; prerr_newline ());
30     raise (Failure str)
31   in
32   ksprintf f fs