Skip to content

Commit 8329a92

Browse files
committed
More diagnostic on spawning a bad executable.
Catch launch error with `Error_Occurred` and resolve error code to get diagnostics. Refs #1129
1 parent 9410a14 commit 8329a92

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

source/ada/lsp-ada_handlers-alire.adb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ package body LSP.Ada_Handlers.Alire is
4141
Process : Spawn.Processes.Process;
4242
Stdout : VSS.Stream_Element_Vectors.Stream_Element_Vector;
4343
Stderr : VSS.Stream_Element_Vectors.Stream_Element_Vector;
44+
Error : Integer := 0; -- Error_Occurred argument
4445
Text : VSS.Strings.Virtual_String; -- Stdout as a text
4546
end record;
4647

@@ -50,13 +51,28 @@ package body LSP.Ada_Handlers.Alire is
5051
overriding procedure Standard_Error_Available
5152
(Self : in out Process_Listener);
5253

54+
overriding procedure Error_Occurred
55+
(Self : in out Process_Listener;
56+
Error : Integer);
57+
5358
procedure Start_Alire
5459
(Listener : in out Process_Listener'Class;
5560
ALR : String;
5661
Option_1 : String;
5762
Option_2 : String;
5863
Root : String);
5964

65+
--------------------
66+
-- Error_Occurred --
67+
--------------------
68+
69+
overriding procedure Error_Occurred
70+
(Self : in out Process_Listener;
71+
Error : Integer) is
72+
begin
73+
Self.Error := Error;
74+
end Error_Occurred;
75+
6076
---------------
6177
-- Run_Alire --
6278
---------------
@@ -158,14 +174,16 @@ package body LSP.Ada_Handlers.Alire is
158174
if Item.Process.Exit_Status /= Spawn.Normal
159175
or else Item.Process.Exit_Code /= 0
160176
or else Decoder.Has_Error
177+
or else Item.Error /= 0
161178
then
162-
Error := "alr";
179+
Error := "'alr";
163180

164181
for Arg of Item.Process.Arguments loop
165182
Error.Append (" ");
166183
Error.Append (VSS.Strings.Conversions.To_Virtual_String (Arg));
167184
end loop;
168185

186+
Error.Append ("' failed:");
169187
Error.Append (VSS.Characters.Latin.Line_Feed);
170188

171189
if Decoder.Has_Error then
@@ -184,6 +202,12 @@ package body LSP.Ada_Handlers.Alire is
184202
Error.Append (Text);
185203
end if;
186204

205+
if Item.Error /= 0 then
206+
Error.Append
207+
(VSS.Strings.Conversions.To_Virtual_String
208+
(GNAT.OS_Lib.Errno_Message (Item.Error)));
209+
end if;
210+
187211
return;
188212
end if;
189213
end loop;

0 commit comments

Comments
 (0)