Skip to content

Commit

Permalink
attempt at fixing errorPrint in webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Sep 30, 2024
1 parent 52acc22 commit 3f0402f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions M2/Macaulay2/d/evaluate.d
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ export evalraw(c:Code):Expr := (
buildErrorPacket(steppingMessage))
else if alarmedFlag then (
clearAlarmedFlag();
stderr << "alarm evalraw " << tostring(c) << endl;
-- stderr << "alarm evalraw " << tostring(c) << endl;
buildErrorPacket(alarmMessage))
else if test(interruptedFlag) then (
SuppressErrors = false;
Expand Down Expand Up @@ -1650,7 +1650,7 @@ export evalexcept(c:Code):Expr := (
if test(exceptionFlag) then ( -- compare this code to the code at the top of eval() above
if alarmedFlag then (
clearAlarmedFlag();
stderr << "alarm evalexcept" << tostring(c) << endl;
-- stderr << "alarm evalexcept" << tostring(c) << endl;
printErrorMessageE(c,alarmMessage))
else if test(interruptedFlag) then (
SuppressErrors = false;
Expand Down
23 changes: 9 additions & 14 deletions M2/Macaulay2/m2/webapp.m2
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,20 @@ timelimit := (t,f) -> (alarm t; r := f(); alarm 0; r)
s := shortMode; shortMode=false;
syms := new MutableHashTable;
recScan := x -> (
if instance(x,VisibleList) or instance(x,Hypertext) or instance(x,Expression) then (
x=apply(x,recScan);
if #x>8 then new class x from { -- simplified short -- TEMP solution
first x,
if instance(x,VectorExpression) or instance(x,VerticalList) then vdots else if instance(x,VisibleList) then ldots else cdots,
last x
}
else x
)
else if class x === Symbol and not syms#?x and (l:=locate x) =!= null then ( syms#x=l; x)
else if class x === String or class x === Option or class x === OptionTable or class x === Keyword then x -- this is ridiculous
if instance(x,VisibleList) or instance(x,Hypertext) or instance(x,Expression) then x=apply(x,recScan);
if instance(x,Symbol) then (if not syms#?x and (l:=locate x) =!= null then syms#x=l; x)
else if class x === String or class x === Option or class x === OptionTable or instance(x,Hypertext) then x -- this is ridiculous
else Abbreviate {x}
);
msg := sequence recScan errorMessage | join apply(toSequence pairs syms,(s,l) -> (BR{}, l, ": here is the first use of ",s));
msg:=recScan \ sequence errorMessage;
h := try html SPAN msg else try html net msg else try html toString msg else try html toExternalString msg;
try print SPAN ((
"class"=>"M2Error",
if errorPosition#1>0 then SPAN{errorPosition,": ","class"=>"M2ErrorLocation"},
if class errorMessage =!= String or substring(errorMessage,0,2) =!= "--" then "error: "
) | msg) else stderr << endl << "--error in conversion of error output to html" << endl; -- should never happen
if class errorMessage =!= String or substring(errorMessage,0,2) =!= "--" then "error: ",
LITERAL h,
) | join apply(toSequence pairs syms,(s,l) -> (BR{}, l, ": here is the first use of ",s))
) else stderr << endl << "--error in conversion of error output to html" << endl; -- should never happen
shortMode=s;
)

Expand Down

0 comments on commit 3f0402f

Please sign in to comment.