[Commit] nickle ChangeLog,1.16,1.17 command.5c,1.18,1.19
Keith Packard
commit at keithp.com
Thu Apr 1 07:48:26 PST 2004
Committed by: keithp
Update of /local/src/CVS/nickle
In directory home.keithp.com:/tmp/cvs-serv7506
Modified Files:
ChangeLog command.5c
Log Message:
2004-04-01 Keith Packard <keithp at keithp.com>
Debian bug 241417
* command.5c:
Catch File::open_error when loading files and print
reasonable message.
exit(1) immediately if an file or library from the
command line fails load.
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/nickle/ChangeLog,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- a/ChangeLog 3 Mar 2004 03:09:54 -0000 1.16
+++ b/ChangeLog 1 Apr 2004 15:48:23 -0000 1.17
@@ -1,3 +1,13 @@
+2004-04-01 Keith Packard <keithp at keithp.com>
+
+ Debian bug 241417
+
+ * command.5c:
+ Catch File::open_error when loading files and print
+ reasonable message.
+ exit(1) immediately if an file or library from the
+ command line fails load.
+
2004-03-02 Keith Packard <keithp at keithp.com>
* debian/changelog:
Index: command.5c
===================================================================
RCS file: /local/src/CVS/nickle/command.5c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- a/command.5c 28 May 2003 23:12:11 -0000 1.18
+++ b/command.5c 1 Apr 2004 15:48:23 -0000 1.19
@@ -85,8 +85,14 @@
*/
void do_load (string f)
{
- if (!lex_file (f))
- File::fprintf (stderr, "Cannot load file \"%s\"\n", f);
+ try {
+ lex_file (f);
+ } catch File::open_error (string msg,
+ File::error_type err,
+ string name) {
+ File::fprintf (stderr, "Cannot load \"%s\": %s\n",
+ name, msg);
+ }
}
new ("load", do_load);
@@ -148,7 +154,7 @@
if (!lex_library (f))
{
File::fprintf (stderr,
- "Cannot load %s " +
+ "Cannot load \"%s\" " +
"file \"%s\", giving up.\n",
autotype,
f);
@@ -279,19 +285,34 @@
lex_file (Environ::get ("HOME") + "/.nicklerc");
} catch invalid_argument (msg, int i, poly value) {
/* do nothing */;
- } catch File::open_error (string name,
+ } catch File::open_error (string msg,
File::error_type err,
- string msg) {
+ string name) {
/* do nothing */;
}
}
while (nfiles-- > 0)
{
- if (files[nfiles].library)
- lex_library (files[nfiles].name);
- else
- lex_file (files[nfiles].name);
+ exception load_fail (string msg);
+ try {
+ if (files[nfiles].library) {
+ if (!lex_library (files[nfiles].name))
+ raise load_fail ("no such library");
+ } else {
+ try {
+ lex_file (files[nfiles].name);
+ } catch File::open_error (string msg,
+ File::error_type err,
+ string name) {
+ raise load_fail (msg);
+ }
+ }
+ } catch load_fail (string msg) {
+ File::fprintf (stderr, "Cannot load \"%s\": %s\n",
+ files[nfiles].name, msg);
+ exit (1);
+ }
}
/*
* Reset argv to hold remaining arguments
More information about the Commit
mailing list