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

feat: improved error message when error in pin #1824

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading