emit more friendly error message on error from piclib loader

This commit is contained in:
Yuichi Nishiwaki 2015-06-26 13:20:49 +09:00
parent 21c12e9fe5
commit fccb4b16ea
2 changed files with 8 additions and 7 deletions

View File

@ -41,7 +41,9 @@ pic_load_piclib(pic_state *pic)
EOL
foreach my $file (@ARGV) {
print " pic_try {\n";
print <<EOL;
pic_try {
EOL
my $var = &escape_v($file);
my $basename = basename($file);
my $dirname = basename(dirname($file));
@ -51,8 +53,7 @@ foreach my $file (@ARGV) {
pic_catch {
/* error! */
xfputs(pic, "fatal error: failure in loading $dirname/$basename\\n", xstderr);
xfputs(pic, pic_errmsg(pic), xstderr);
pic_panic(pic, "load error");
pic_raise(pic, pic->err);
}
EOL
}

View File

@ -44,11 +44,11 @@ main(int argc, char *argv[], char **envp)
pic = pic_open(pic_default_allocf, NULL);
pic_set_argv(pic, argc, argv, envp);
pic_init_picrin(pic);
PICRIN_MAIN = pic_find_library(pic, pic_read_cstr(pic, "(picrin main)"));
pic_try {
pic_init_picrin(pic);
PICRIN_MAIN = pic_find_library(pic, pic_read_cstr(pic, "(picrin main)"));
pic_funcall(pic, PICRIN_MAIN, "main", pic_nil_value());
}
pic_catch {