Skip to content

Commit

Permalink
feat: improved reporting for errors in linked crates (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo authored Jan 23, 2025
1 parent 1c4d02a commit 20c2984
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/alire/alire-errors.adb
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,17 @@ package body Alire.Errors is
-- Pretty_Print --
------------------

procedure Pretty_Print (Error : String) is
procedure Pretty_Print (Error : String;
Level : Trace.Levels := Trace.Error)
is
Lines : constant AAA.Strings.Vector := Split (Error, ASCII.LF);
begin
for I in Lines.First_Index .. Lines.Last_Index loop
declare
Line : constant String := Trim (Lines (I));
begin
if Line /= "" then
Trace.Error
Trace.Log
((if I > Lines.First_Index then " " else "")
-- Indentation

Expand All @@ -146,11 +148,11 @@ package body Alire.Errors is
& (if I < Lines.Last_Index
and then Line (Line'Last) /= ':'
then ":"
else "")
else ""),
-- Trailing ':' except for last line
);
Level);
else
Trace.Error (Line);
Trace.Log (Line, Level);
end if;
end;
end loop;
Expand Down
3 changes: 2 additions & 1 deletion src/alire/alire-errors.ads
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ package Alire.Errors with Preelaborate is
-- Returns the error for Ex if it exists, or defaults to Exception_Message.
-- The stored error is cleared.

procedure Pretty_Print (Error : String);
procedure Pretty_Print (Error : String;
Level : Trace.Levels := Trace.Error);
-- Split Error at LFs to prefix each sub-error in a new line with the
-- appropriate tracing prefix. Also, from the second line on, messages are
-- indented. This way, several top-level errors are easier to distinguish.
Expand Down
10 changes: 7 additions & 3 deletions src/alire/alire-user_pins.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
with Ada.Directories;

with Alire.Directories;
with Alire.Errors;
with Alire.Origins;
with Alire.Roots.Optional;
with Alire.Utils.User_Input;
Expand Down Expand Up @@ -363,9 +364,12 @@ package body Alire.User_Pins is

if not Root.Is_Valid then
Put_Warning
("Pin for " & Utils.TTY.Name (Crate) &
" does not contain an Alire " &
"manifest. It will be used as a raw GNAT project.");
("Pin for " & Utils.TTY.Name (Crate) & " at "
& Utils.TTY.URL (Destination)
& " does not contain a valid Alire manifest. "
& "It will be used as a raw GNAT project.");
Errors.Pretty_Print
("Pin diagnostic is:" & New_Line & Root.Message, Trace.Warning);
end if;

end;
Expand Down
3 changes: 2 additions & 1 deletion testsuite/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This docker image is used in tests with the `docker_wrapper` driver.

FROM alire/gnat:ubuntu-lts
# Latest tested is 24.04
FROM alire/gnat:ubuntu-lts

RUN useradd -m -s /bin/bash user && \
chown user:user /home/user && \
Expand Down

0 comments on commit 20c2984

Please sign in to comment.