(* by Jun Furuse, to get string of exc. , modified printexc.ml *)
(* FRX: removed the "Uncaught exception: " string *)

let f = function
    Out_of_memory ->
      "Out of memory"
  | Match_failure(file, first_char, last_char) ->
      "Pattern matching failed, file " ^
      file ^
      ", chars " ^ string_of_int first_char ^
      "-" ^ string_of_int last_char
  | x ->
      (Obj.magic(Obj.field (Obj.field (Obj.repr x) 0) 0)) ^
      if Obj.size (Obj.repr x) > 1 then begin
        "(" ^
        let rec loop i = 
	  if i = Obj.size (Obj.repr x) then ""
	  else
      	    ((if i > 1 then ", " else "") ^  
             let arg = Obj.field (Obj.repr x) i in
             if not (Obj.is_block arg) then
               string_of_int (Obj.magic arg : int)
             else if Obj.tag arg = 252 then 
               "\""^(Obj.magic arg : string)^"\""
             else
               "_") ^ loop (i + 1)
	 in loop 1 ^      
        ")"
      end
      	else ""
