added transform_error, exception ERROR_MESSAGE;
authorwenzelm
Wed, 13 May 1998 19:05:50 +0200
changeset 4923 ec71c480e600
parent 4922 03b81b6e1baa
child 4924 cf6bb75968c4
added transform_error, exception ERROR_MESSAGE;
src/Pure/library.ML
--- a/src/Pure/library.ML	Wed May 13 12:23:28 1998 +0200
+++ b/src/Pure/library.ML	Wed May 13 19:05:50 1998 +0200
@@ -215,6 +215,8 @@
   val get_error: 'a error -> string option
   val get_ok: 'a error -> 'a option
   val handle_error: ('a -> 'b) -> 'a -> 'b error
+  exception ERROR_MESSAGE of string
+  val transform_error: ('a -> 'b) -> 'a -> 'b
 
   (*timing*)
   val cond_timeit: bool -> (unit -> 'a) -> 'a
@@ -1061,6 +1063,16 @@
   end;
 
 
+(* transform ERROR into ERROR_MESSAGE, capturing the side-effect *)
+
+exception ERROR_MESSAGE of string;
+
+fun transform_error f x =
+  (case handle_error f x of
+    OK y => y
+  | Error msg => raise ERROR_MESSAGE msg);
+
+
 
 (** timing **)