summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-07-06 16:38:17 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-07-06 16:38:17 +0200
commit13c8a8e6c4595686ee3ce7d6cd0be6b4838e0dba (patch)
treeff54ef20225a5f5dda64a08ab79ba8f05be77aaf
parent31a9d8c4a59a2128cf345c3a00b0966cb31a6201 (diff)
Make the REPL not segfault upon errors when loading init.lisp.
-rw-r--r--MLKReadEvalPrintLoop.m22
1 files changed, 16 insertions, 6 deletions
diff --git a/MLKReadEvalPrintLoop.m b/MLKReadEvalPrintLoop.m
index 8c06496..1005ac7 100644
--- a/MLKReadEvalPrintLoop.m
+++ b/MLKReadEvalPrintLoop.m
@@ -80,13 +80,23 @@ static const char *prompt (EditLine *e) {
el_set (editline, EL_HIST, history, commands);
printf ("Loading init.lisp.\n");
- input = [NSInputStream inputStreamWithFileAtPath:@"init.lisp"];
- stream = AUTORELEASE ([[MLKStream alloc] initWithInputStream:input]);
+ NS_DURING
+ {
+ input = [NSInputStream inputStreamWithFileAtPath:@"init.lisp"];
+ stream = AUTORELEASE ([[MLKStream alloc] initWithInputStream:input]);
- [input open];
- [MLKInterpreter load:stream verbose:YES print:YES];
- success = [MLKInterpreter load:stream verbose:YES print:YES];
- [input close];
+ [input open];
+ [MLKInterpreter load:stream verbose:YES print:YES];
+ success = [MLKInterpreter load:stream verbose:YES print:YES];
+ [input close];
+ }
+ NS_HANDLER
+ {
+ printf ("Caught an unhandled exception.\nName: %s\nReason: %s\n",
+ [[localException name] UTF8String],
+ [[localException reason] UTF8String]);
+ }
+ NS_ENDHANDLER;
printf ("Done.\n\n");