Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New GAP-level variable ErrorOutput for "*errout*" #2824

Merged
merged 2 commits into from
Sep 21, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Adapt lib/error.g to use ERROR_OUTPUT
Makes all functions in error.g use ERROR_OUTPUT instead of the magic
string "*errout*". Then the error messages can be redirected by
overwriting ERROR_OUTPUT.

This should be temporary. If the target of "*errout*" itself can be
changed, this can be reverted again. See #2822.
  • Loading branch information
ssiccha committed Sep 21, 2018
commit 7a4ede8a01c0177cfdfc62ea8079dd301978f200
40 changes: 20 additions & 20 deletions lib/error.g
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,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(ERROR_OUTPUT, context);
PrintTo(ERROR_OUTPUT, " called from\n");
lastcontext := context;
context := ParentLVars(context);
depth := depth-1;
od;
if depth = 0 then
PrintTo("*errout*", "... ");
PrintTo(ERROR_OUTPUT, "... ");
else
f := ContentsLVars(lastcontext).func;
PrintTo("*errout*", "<function \"",NAME_FUNC(f)
PrintTo(ERROR_OUTPUT, "<function \"",NAME_FUNC(f)
,"\">( <arguments> )\n called from read-eval loop ");
fi;
end);
Expand All @@ -85,11 +85,11 @@ BIND_GLOBAL("Where", function(arg)
fi;

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

OnBreak := Where;
Expand Down Expand Up @@ -126,15 +126,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(ERROR_OUTPUT, "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(ERROR_OUTPUT, "ErrorInner: option justQuit must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -145,7 +145,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(ERROR_OUTPUT, "ErrorInner: option mayReturnVoid must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -156,7 +156,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(ERROR_OUTPUT, "ErrorInner: option mayReturnObj must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -167,7 +167,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(ERROR_OUTPUT, "ErrorInner: option printThisStatement must be true or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -178,7 +178,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(ERROR_OUTPUT, "ErrorInner: option lateMessage must be a string or false\n");
LEAVE_ALL_NAMESPACES();
JUMP_TO_CATCH(1);
fi;
Expand All @@ -188,7 +188,7 @@ BIND_GLOBAL("ErrorInner",

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

ErrorLevel := ErrorLevel+1;
Expand All @@ -235,14 +235,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(ERROR_OUTPUT);
if AlwaysPrintTracebackOnError then
printEarlyTraceback("*errout*");
printEarlyTraceback(ERROR_OUTPUT);
if IsBound(OnBreak) and IsFunction(OnBreak) then
OnBreak();
fi;
else
PrintTo("*errout*", "\n");
PrintTo(ERROR_OUTPUT, "\n");
fi;
fi;
if IsHPCGAP then
Expand Down Expand Up @@ -272,8 +272,8 @@ BIND_GLOBAL("ErrorInner",
JUMP_TO_CATCH(0);
fi;

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

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

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