summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-24 16:17:17 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-24 16:17:17 +0200
commit6684d33bab073d267198ef7159cb627c2ecddc0a (patch)
tree61b29732ef0892dd0a62a0eac2fe3965ce8b7045
parent2283b43f733d95fe1c95fd0b7b838a1d450b007a (diff)
Make the read-eval-print loop more robust in the face of exceptions.
-rw-r--r--MLKReadEvalPrintLoop.m23
1 files changed, 17 insertions, 6 deletions
diff --git a/MLKReadEvalPrintLoop.m b/MLKReadEvalPrintLoop.m
index 392b4ed..4ccc339 100644
--- a/MLKReadEvalPrintLoop.m
+++ b/MLKReadEvalPrintLoop.m
@@ -39,12 +39,23 @@ static char **_argv;
static const char *prompt (EditLine *e) {
- MLKPackage *package = [[MLKDynamicContext currentContext]
- valueForSymbol:[[MLKPackage
- findPackage:@"COMMON-LISP"]
- intern:@"*PACKAGE*"]];
-
- return [[NSString stringWithFormat:@"%@> ", [package name]] UTF8String];
+ NS_DURING
+ {
+ MLKPackage *package = [[MLKDynamicContext currentContext]
+ valueForSymbol:[[MLKPackage
+ findPackage:@"COMMON-LISP"]
+ intern:@"*PACKAGE*"]];
+
+ return [[NSString stringWithFormat:@"%@> ", [package name]] UTF8String];
+ }
+ NS_HANDLER
+ {
+ printf ("Caught an unhandled exception.\nName: %s\nReason: %s\n",
+ [[localException name] UTF8String],
+ [[localException reason] UTF8String]);
+ return "> ";
+ }
+ NS_ENDHANDLER
}