diff options
Diffstat (limited to 'lib/system.ml')
| -rw-r--r-- | lib/system.ml | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/system.ml b/lib/system.ml index ed23bde197..41201bd2d3 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 -> |
