Commit aa51dd43 authored by Pietro Abate's avatar Pietro Abate

[r2003-07-24 13:21:32 by cvscast] Bug in pretty printing exceptions in the web interface

Original author: cvscast
Date: 2003-07-24 13:21:32+00:00
parent 890d30fe
......@@ -28,7 +28,6 @@ let print_sample ppf s =
let print_protect ppf s =
Location.protect ppf (fun ppf -> Format.fprintf ppf "%s" s)
let print_value ppf v =
Location.protect ppf (fun ppf -> Value.print ppf v)
......@@ -49,7 +48,7 @@ let dump_env ppf =
let rec print_exn ppf = function
| Location (loc, w, exn) ->
Format.fprintf ppf "Error %a:@." Location.print_loc (loc,w);
Format.fprintf ppf "%a" Location.html_hilight (loc,w);
Format.fprintf ppf "%a" Location.html_hilight (loc,w);
print_exn ppf exn
| Value.CDuceExn v ->
Format.fprintf ppf "Uncaught CDuce exception: @[%a@]@."
......@@ -63,16 +62,16 @@ let rec print_exn ppf = function
Format.fprintf ppf "not present in an expression of type:@.%a@."
print_norm t
| Typer.ShouldHave (t,msg) ->
Format.fprintf ppf "This expression should have type:@.%a@.%s@."
Format.fprintf ppf "This expression should have type:@.%a@.%a@."
print_norm t
msg
print_protect msg
| Typer.ShouldHave2 (t1,msg,t2) ->
Format.fprintf ppf "This expression should have type:@.%a@.%s %a@."
Format.fprintf ppf "This expression should have type:@.%a@.%a %a@."
print_norm t1
msg
print_protect msg
print_norm t2
| Typer.Error s ->
Format.fprintf ppf "%s@." s
Format.fprintf ppf "%a@." print_protect s
| Typer.Constraint (s,t) ->
Format.fprintf ppf "This expression should have type:@.%a@."
print_norm t;
......@@ -88,7 +87,7 @@ let rec print_exn ppf = function
| Typer.UnboundId x ->
Format.fprintf ppf "Unbound identifier %a@." U.print (Id.value x)
| Wlexer.Illegal_character c ->
Format.fprintf ppf "Illegal character (%s)@." (Char.escaped c)
Format.fprintf ppf "Illegal character (%a)@." print_protect (Char.escaped c)
| Wlexer.Unterminated_comment ->
Format.fprintf ppf "Comment not terminated@."
| Wlexer.Unterminated_string ->
......@@ -96,12 +95,12 @@ let rec print_exn ppf = function
| Wlexer.Unterminated_string_in_comment ->
Format.fprintf ppf "This comment contains an unterminated string literal@."
| Parser.Error s | Stream.Error s ->
Format.fprintf ppf "Parsing error: %s@." s
Format.fprintf ppf "Parsing error: %a@." print_protect s
| Location.Generic s ->
Format.fprintf ppf "%s@." s
Format.fprintf ppf "%a@." print_protect s
| exn ->
(* raise exn *)
Format.fprintf ppf "%s@." (Printexc.to_string exn)
Format.fprintf ppf "%a@." print_protect (Printexc.to_string exn)
let debug ppf = function
| `Subtype (t1,t2) ->
......
......@@ -88,16 +88,17 @@ let dump_loc ppf ((src,i,j),w) =
| _ -> ()
let rec beg_of_line s i =
if (i = 0) || (s.[i-1] = '\n') || (s.[i-1] = '\r')
if (i <= 0) || (s.[i-1] = '\n') || (s.[i-1] = '\r')
then i else beg_of_line s (i - 1)
let rec end_of_line s i =
if (i = String.length s) || (s.[i] = '\n') || (s.[i] = '\r')
if (i >= String.length s) || (s.[i] = '\n') || (s.[i] = '\r')
then i else end_of_line s (i + 1)
let html_hilight ppf ((src,i,j),w) =
match (src, !viewport) with
| `String s, `Html ->
(try
if (i < 0) then
Format.fprintf ppf "<b>GHOST LOCATION</b>@\n"
else
......@@ -108,6 +109,7 @@ let html_hilight ppf ((src,i,j),w) =
(extr s i0 i)
(extr s i j)
(extr s j j0)
with e -> failwith "html_hilight")
| _ -> ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment