Skip to content

Commit

Permalink
Fix error deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Nov 2, 2023
1 parent da51685 commit fcb8f38
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/alire/alire-errors.adb
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ package body Alire.Errors is

procedure Open (Text : String) is
begin
if Error_Stack.Is_Empty or else Error_Stack.Last_Element /= Text then
Error_Stack.Append (Text);
end if;
Error_Stack.Append (Text);
end Open;

-----------
Expand Down Expand Up @@ -217,8 +215,15 @@ package body Alire.Errors is
Msg : UString;
use UStrings;
begin
for Item of Error_Stack loop
Append (Msg, Item & ASCII.LF);
-- Remove duplicates that may have creeped in when generating the final
-- stack:

for I in Error_Stack.First_Index .. Error_Stack.Last_Index loop
if I = Error_Stack.First_Index
or else Error_Stack (I) /= Error_Stack (I - 1)
then
Append (Msg, Error_Stack (I) & ASCII.LF);
end if;
end loop;

return +Msg & Text;
Expand Down

0 comments on commit fcb8f38

Please sign in to comment.