diff --git a/boot/init.pl b/boot/init.pl index 67a2387575..4601b3fcfa 100644 --- a/boot/init.pl +++ b/boot/init.pl @@ -1869,6 +1869,7 @@ '$must_be'(list, Options), '$load_files'(Files, Module, Options). +:- dynamic '$load_file_exception'/1. '$load_files'(X, _, _) :- var(X), !, @@ -1885,7 +1886,11 @@ List = [_|_], !, '$must_be'(list, List), - '$load_file_list'(List, Module, Options). + '$load_file_list'(List, Module, Options), + ( '$load_file_exception'(E) + -> throw(E) + ; true + ). '$load_files'(File, Module, Options) :- '$load_one_file'(File, Module, Options). @@ -1893,7 +1898,7 @@ '$load_file_list'([File|Rest], Module, Options) :- E = error(_,_), catch('$load_one_file'(File, Module, Options), E, - '$print_message'(error, E)), + assertz('$load_file_exception'(E)) ), '$load_file_list'(Rest, Module, Options). diff --git a/boot/toplevel.pl b/boot/toplevel.pl index 762fe5678c..3aa5138515 100644 --- a/boot/toplevel.pl +++ b/boot/toplevel.pl @@ -733,13 +733,19 @@ % Toplevel called when invoked with -c option. '$compile' :- + ( catch('$compile_', E, (print_message(error, E), halt(2))) + -> true + ; halt(1) + ). + +'$compile_' :- '$load_system_init_file', '$set_file_search_paths', init_debug_flags, '$run_initialization', attach_packs, use_module(library(qsave)), - catch(qsave:qsave_toplevel, E, (print_message(error, E), halt(1))). + qsave:qsave_toplevel. %! '$config' %