about summary refs log tree commit diff stats
path: root/081run_interactive.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-01 13:13:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-01 13:13:10 -0700
commit4814bf94e75ffdcbd2a4093eb1ab67851980a37a (patch)
tree9fde405360c5499fa2ad4b25ca009ed3bcc1f57b /081run_interactive.cc
parent5fdd8e96adcf6f572888078caee62adbee1906a4 (diff)
downloadmu-4814bf94e75ffdcbd2a4093eb1ab67851980a37a.tar.gz
2226 - standardize warning format
Always show recipe name where error occurred. But don't show internal
'interactive' name for sandboxes, that's just confusing.

What started out as warnings are now ossifying into errors that halt all
execution. Is this how things went with C and Unix as well?
Diffstat (limited to '081run_interactive.cc')
-rw-r--r--081run_interactive.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/081run_interactive.cc b/081run_interactive.cc
index dd3fc5c3..eccf2d07 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -29,11 +29,11 @@ Recipe_ordinal["run-interactive"] = RUN_INTERACTIVE;
 :(before "End Primitive Recipe Implementations")
 case RUN_INTERACTIVE: {
   if (SIZE(ingredients) != 1) {
-    raise << current_recipe_name() << ": 'run-interactive' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+    raise << maybe(current_recipe_name()) << "'run-interactive' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
     break;
   }
   if (!scalar(ingredients.at(0))) {
-    raise << current_recipe_name() << ": first ingredient of 'run-interactive' should be a string, but got " << current_instruction().ingredients.at(0).to_string() << '\n' << end();
+    raise << maybe(current_recipe_name()) << "first ingredient of 'run-interactive' should be a string, but got " << current_instruction().ingredients.at(0).to_string() << '\n' << end();
     break;
   }
   bool new_code_pushed_to_stack = run_interactive(ingredients.at(0).at(0));
@@ -140,6 +140,10 @@ load(string(
 transform_all();
 recently_added_recipes.clear();
 
+//: adjust warnings in the sandbox
+:(after "string maybe(string s)")
+  if (s == "interactive") return "";
+
 :(scenario run_interactive_comments)
 recipe main [
   1:address:array:character <- new [# ab
@@ -342,11 +346,11 @@ Recipe_ordinal["reload"] = RELOAD;
 :(before "End Primitive Recipe Implementations")
 case RELOAD: {
   if (SIZE(ingredients) != 1) {
-    raise << current_recipe_name() << ": 'reload' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
+    raise << maybe(current_recipe_name()) << "'reload' requires exactly one ingredient, but got " << current_instruction().to_string() << '\n' << end();
     break;
   }
   if (!scalar(ingredients.at(0))) {
-    raise << current_recipe_name() << ": first ingredient of 'reload' should be a literal string, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
+    raise << maybe(current_recipe_name()) << "first ingredient of 'reload' should be a literal string, but got " << current_instruction().ingredients.at(0).original_string << '\n' << end();
     break;
   }
   // clear any containers in advance