From 17f729e2dbd5b804b2f803153d36d2956300c587 Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Tue, 26 Mar 2024 08:38:00 +0100 Subject: [PATCH] [hxb] add compiler failure message --- src/compiler/hxb/hxbReader.ml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/compiler/hxb/hxbReader.ml b/src/compiler/hxb/hxbReader.ml index 0f5e8074d61..f5f98e769a2 100644 --- a/src/compiler/hxb/hxbReader.ml +++ b/src/compiler/hxb/hxbReader.ml @@ -1973,11 +1973,30 @@ class hxb_reader | EOM -> incr stats.modules_fully_restored; + method private die chunk msg = + let msg = + (Printf.sprintf "Compiler failure while reading hxb chunk %s of %s: %s\n" (string_of_chunk_kind chunk) (s_type_path mpath) (msg)) + ^ "Please submit an issue at https://github.com/HaxeFoundation/haxe/issues/new\n" + ^ "Attach the following information:" + in + let backtrace = Printexc.raw_backtrace_to_string (Printexc.get_raw_backtrace ()) in + let backtrace = + try snd (ExtString.String.split backtrace "\n") + with ExtString.Invalid_string -> backtrace + in + let s = Printf.sprintf "%s\nHaxe: %s\n%s" msg s_version_full backtrace in + failwith s + method private read_chunk_data kind = let path = String.concat "_" (ExtLib.String.nsplit (s_type_path mpath) ".") in let id = ["hxb";"read";string_of_chunk_kind kind;path] in let close = Timer.timer id in - self#read_chunk_data' kind; + try + self#read_chunk_data' kind + with Invalid_argument msg -> begin + close(); + self#die kind msg + end; close() method read_chunks (new_api : hxb_reader_api) (chunks : cached_chunks) =