Skip to content

Commit

Permalink
Adapt lib/error.g to use ErrorOutput
Browse files Browse the repository at this point in the history
Makes all functions in error.g use ErrorOutput instead of the magic
string "*errout*". Then the error messages can be redirected by
overwriting ErrorOutput.

This should be temporary. If the target of "*errout*" itself can be
changed, this can be reverted again. See gap-system#2822.
  • Loading branch information
ssiccha committed Sep 18, 2018
1 parent 8ae8a26 commit 9645f68
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/error.g
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ BIND_GLOBAL("WHERE", function( context, depth, outercontext)
bottom := GetBottomLVars();
lastcontext := outercontext;
while depth > 0 and context <> bottom do
PRINT_CURRENT_STATEMENT("*errout*", context);
PrintTo("*errout*", " called from\n");
PRINT_CURRENT_STATEMENT(ErrorOutput, context);
PrintTo(ErrorOutput, " called from\n");
lastcontext := context;
context := ParentLVars(context);
depth := depth-1;
od;
if depth = 0 then
PrintTo("*errout*", "... ");
PrintTo(ErrorOutput, "... ");
else
f := ContentsLVars(lastcontext).func;
PrintTo("*errout*", "<function \"",NAME_FUNC(f)
PrintTo(ErrorOutput, "<function \"",NAME_FUNC(f)
,"\">( <arguments> )\n called from read-eval loop ");
fi;
end);
Expand All @@ -81,11 +81,11 @@ BIND_GLOBAL("Where", function(arg)
fi;

if ErrorLVars = fail or ErrorLVars = GetBottomLVars() then
PrintTo("*errout*", "not in any function ");
PrintTo(ErrorOutput, "not in any function ");
else
WHERE(ParentLVars(ErrorLVars),depth, ErrorLVars);
fi;
PrintTo("*errout*", "at ",INPUT_FILENAME(),":",INPUT_LINENUMBER(),"\n");
PrintTo(ErrorOutput, "at ",INPUT_FILENAME(),":",INPUT_LINENUMBER(),"\n");
end);

OnBreak := Where;
Expand Down Expand Up @@ -122,15 +122,15 @@ BIND_GLOBAL("ErrorInner",

context := arg[1].context;
if not IsLVarsBag(context) then
PrintTo("*errout*", "ErrorInner: option context must be a local variables bag\n");
PrintTo(ErrorOutput, "ErrorInner: option context must be a local variables bag\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;

if IsBound(arg[1].justQuit) then
justQuit := arg[1].justQuit;
if not justQuit in [false, true] then
PrintTo("*errout*", "ErrorInner: option justQuit must be true or false\n");
PrintTo(ErrorOutput, "ErrorInner: option justQuit must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -141,7 +141,7 @@ BIND_GLOBAL("ErrorInner",
if IsBound(arg[1].mayReturnVoid) then
mayReturnVoid := arg[1].mayReturnVoid;
if not mayReturnVoid in [false, true] then
PrintTo("*errout*", "ErrorInner: option mayReturnVoid must be true or false\n");
PrintTo(ErrorOutput, "ErrorInner: option mayReturnVoid must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -152,7 +152,7 @@ BIND_GLOBAL("ErrorInner",
if IsBound(arg[1].mayReturnObj) then
mayReturnObj := arg[1].mayReturnObj;
if not mayReturnObj in [false, true] then
PrintTo("*errout*", "ErrorInner: option mayReturnObj must be true or false\n");
PrintTo(ErrorOutput, "ErrorInner: option mayReturnObj must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -163,7 +163,7 @@ BIND_GLOBAL("ErrorInner",
if IsBound(arg[1].printThisStatement) then
printThisStatement := arg[1].printThisStatement;
if not printThisStatement in [false, true] then
PrintTo("*errout*", "ErrorInner: option printThisStatement must be true or false\n");
PrintTo(ErrorOutput, "ErrorInner: option printThisStatement must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -174,7 +174,7 @@ BIND_GLOBAL("ErrorInner",
if IsBound(arg[1].lateMessage) then
lateMessage := arg[1].lateMessage;
if not lateMessage in [false, true] and not IsString(lateMessage) then
PrintTo("*errout*", "ErrorInner: option lateMessage must be a string or false\n");
PrintTo(ErrorOutput, "ErrorInner: option lateMessage must be a string or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -184,7 +184,7 @@ BIND_GLOBAL("ErrorInner",

earlyMessage := arg[2];
if Length(arg) <> 2 then
PrintTo("*errout*", "ErrorInner: new format takes exactly two arguments\n");
PrintTo(ErrorOutput, "ErrorInner: new format takes exactly two arguments\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand Down Expand Up @@ -213,7 +213,7 @@ BIND_GLOBAL("ErrorInner",
fi;
PrintTo(stream, " called from");
fi;
PrintTo("*errout*", "\n");
PrintTo(ErrorOutput, "\n");
end;

ErrorLevel := ErrorLevel+1;
Expand All @@ -231,14 +231,14 @@ BIND_GLOBAL("ErrorInner",
# It is used by HPC-GAP to e.g. suppress error messages in worker
# threads.
if not SilentNonInteractiveErrors then
printEarlyMessage("*errout*");
printEarlyMessage(ErrorOutput);
if AlwaysPrintTracebackOnError then
printEarlyTraceback("*errout*");
printEarlyTraceback(ErrorOutput);
if IsBound(OnBreak) and IsFunction(OnBreak) then
OnBreak();
fi;
else
PrintTo("*errout*", "\n");
PrintTo(ErrorOutput, "\n");
fi;
fi;
if IsHPCGAP then
Expand Down Expand Up @@ -268,8 +268,8 @@ BIND_GLOBAL("ErrorInner",
JUMP_TO_CATCH(0);
fi;

printEarlyMessage("*errout*");
printEarlyTraceback("*errout*");
printEarlyMessage(ErrorOutput);
printEarlyTraceback(ErrorOutput);

if SHOULD_QUIT_ON_BREAK() then
# Again, the default is to not print the rest of the traceback.
Expand All @@ -288,7 +288,7 @@ BIND_GLOBAL("ErrorInner",

# Now print lateMessage and OnBreakMessage a la "press return; to .."
if IsString(lateMessage) then
PrintTo("*errout*", lateMessage,"\n");
PrintTo(ErrorOutput, lateMessage,"\n");
elif lateMessage then
if IsBound(OnBreakMessage) and IsFunction(OnBreakMessage) then
OnBreakMessage();
Expand Down

0 comments on commit 9645f68

Please sign in to comment.