aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGravatar herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7>2013-02-01 20:54:30 +0000
committerGravatar herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7>2013-02-01 20:54:30 +0000
commit4e815cf82079e7b52f610d74a4bb1325ad408239 (patch)
tree99e6566d34091915092609f7fc31e941b721f6dc /lib
parent3b342fc581294fe16ad53c71832ba61c0f717bd1 (diff)
v8.4: Granting bug/wish #2976 (turning anomaly on input_value into nice message)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16183 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
-rw-r--r--lib/system.ml8
-rw-r--r--lib/system.mli2
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/system.ml b/lib/system.ml
index ed23bde19..41201bd2d 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -113,9 +113,11 @@ let try_remove filename =
(str"Could not remove file " ++ str filename ++ str" which is corrupted!")
let marshal_out ch v = Marshal.to_channel ch v []
-let marshal_in ch =
+let marshal_in filename ch =
try Marshal.from_channel ch
- with End_of_file -> error "corrupted file: reached end of file"
+ with
+ | End_of_file | Failure _ (* e.g. "truncated object" *) ->
+ error (filename ^ " is corrupted, try to rebuild it.")
exception Bad_magic_number of string
@@ -150,7 +152,7 @@ let extern_intern ?(warn=true) magic suffix =
try
let _,filename = find_file_in_path ~warn paths (CUnix.make_suffix name suffix) in
let channel = raw_intern filename in
- let v = marshal_in channel in
+ let v = marshal_in filename channel in
close_in channel;
v
with Sys_error s ->
diff --git a/lib/system.mli b/lib/system.mli
index 0daf38b74..8cbbb9cab 100644
--- a/lib/system.mli
+++ b/lib/system.mli
@@ -32,7 +32,7 @@ val find_file_in_path :
when the check fails, with the full file name. *)
val marshal_out : out_channel -> 'a -> unit
-val marshal_in : in_channel -> 'a
+val marshal_in : string -> in_channel -> 'a
exception Bad_magic_number of string