@@ -185,7 +185,7 @@ BIND_GLOBAL("ErrorInner",
185185 LEAVE_ALL_NAMESPACES();
186186 JUMP_TO_CATCH(1 );
187187 fi ;
188-
188+
189189 # Local functions that print the user feedback.
190190 printEarlyMessage := function (stream, earlyMessage )
191191 PrintTo(stream, " Error, " );
@@ -222,12 +222,21 @@ BIND_GLOBAL("ErrorInner",
222222 if QUITTING or not BreakOnError then
223223 # If we skip the break loop, the standard behaviour is to print only
224224 # the earlyMessage. If SilentNonInteractiveErrors is true we do not
225- # print any messages.
226- # This is used by HPC-GAP to e.g. suppress error messages in worker
225+ # print any messages. If AlwaysPrintTracebackOnError is true we also
226+ # call OnBreak(), which by default prints the traceback.
227+ # SilentNonInteractiveErrors superseeds AlwaysPrintTracebackOnError.
228+ # It is used by HPC-GAP to e.g. suppress error messages in worker
227229 # threads.
228230 if not SilentNonInteractiveErrors then
229231 printEarlyMessage(" *errout*" , earlyMessage);
230- PrintTo(" *errout*" , " \n " );
232+ if AlwaysPrintTracebackOnError then
233+ printEarlyTraceback(" *errout*" , context, printThisStatement);
234+ if IsBound (OnBreak) and IsFunction(OnBreak) then
235+ OnBreak();
236+ fi ;
237+ else
238+ PrintTo(" *errout*" , " \n " );
239+ fi ;
231240 fi ;
232241 if IsHPCGAP then
233242 # In HPC-GAP we want to access error messages encountered in
@@ -236,6 +245,17 @@ BIND_GLOBAL("ErrorInner",
236245 LastErrorMessage := " " ;
237246 lastErrorStream := OutputTextString(LastErrorMessage, true );
238247 printEarlyMessage(lastErrorStream, earlyMessage);
248+ if AlwaysPrintTracebackOnError then
249+ printEarlyTraceback(lastErrorStream, context, printThisStatement);
250+ # FIXME: Also make HPCGAP work with OnBreak().
251+ # If AlwaysPrintTracebackOnError is true, the output of
252+ # OnBreak() should also be put into LastErrorMessage.
253+ # To do this there needs to be a way to put its output
254+ # into lastErrorStream.
255+ # OnBreak() is documented to not take any arguments.
256+ # One could work around that if there were e.g. a GAP error
257+ # stream which all error functions print to.
258+ fi ;
239259 CloseStream(lastErrorStream);
240260 MakeImmutable(LastErrorMessage);
241261 fi ;
@@ -249,6 +269,14 @@ BIND_GLOBAL("ErrorInner",
249269 printEarlyTraceback(" *errout*" , context, printThisStatement);
250270
251271 if SHOULD_QUIT_ON_BREAK() then
272+ # Again, the default is to not print the rest of the traceback.
273+ # If AlwaysPrintTracebackOnError is true we do so anyways.
274+ if
275+ AlwaysPrintTracebackOnError
276+ and IsBound (OnBreak) and IsFunction(OnBreak)
277+ then
278+ OnBreak();
279+ fi ;
252280 FORCE_QUIT_GAP(1 );
253281 fi ;
254282
0 commit comments