Commit e1061afa authored by yoogx's avatar yoogx

* Allow Exit_On_Error to raise an exception, required for the

          Python bindings.

          For ticket #37
parent 8b83ae06
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2014 ESA & ISAE. -- -- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify -- -- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the -- -- it under terms of the GNU General Public License as published by the --
...@@ -39,6 +39,17 @@ with Ocarina.Namet; use Ocarina.Namet; ...@@ -39,6 +39,17 @@ with Ocarina.Namet; use Ocarina.Namet;
package body Errors is package body Errors is
---------------------------
-- Use_Exception_To_Exit --
---------------------------
Use_Exception : Boolean := True;
procedure Use_Exception_To_Exit is
begin
Use_Exception := True;
end Use_Exception_To_Exit;
procedure Internal_Display_Message (S : String); procedure Internal_Display_Message (S : String);
procedure Check_Space; procedure Check_Space;
...@@ -230,9 +241,13 @@ package body Errors is ...@@ -230,9 +241,13 @@ package body Errors is
begin begin
if Error then if Error then
Set_Standard_Error; Set_Standard_Error;
if Use_Exception then
raise Ocarina_Error with Reason;
else
Write_Line (Reason); Write_Line (Reason);
OS_Exit (1); OS_Exit (1);
end if; end if;
end if;
end Exit_On_Error; end Exit_On_Error;
end Errors; end Errors;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2012-2014 ESA & ISAE. -- -- Copyright (C) 2012-2015 ESA & ISAE. --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify -- -- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the -- -- it under terms of the GNU General Public License as published by the --
...@@ -68,6 +68,14 @@ package Errors is ...@@ -68,6 +68,14 @@ package Errors is
procedure Display_Bug_Box (E : Ada.Exceptions.Exception_Occurrence); procedure Display_Bug_Box (E : Ada.Exceptions.Exception_Occurrence);
-- Error reporting
-- * by default, Exit_On_Error directly exists;
-- * if Use_Exception_To_Exit is called, Exit_On_Error raises the
-- Ocarina_Error exception
procedure Use_Exception_To_Exit;
Ocarina_Error : exception;
procedure Exit_On_Error (Error : Boolean; Reason : String); procedure Exit_On_Error (Error : Boolean; Reason : String);
end Errors; end Errors;
...@@ -42,6 +42,7 @@ with Ocarina.Configuration; use Ocarina.Configuration; ...@@ -42,6 +42,7 @@ with Ocarina.Configuration; use Ocarina.Configuration;
with GNATCOLL.VFS; use GNATCOLL.VFS; with GNATCOLL.VFS; use GNATCOLL.VFS;
with Ocarina.Output; use Ocarina.Output; with Ocarina.Output; use Ocarina.Output;
with Errors;
with Ocarina.Types; use Ocarina.Types; with Ocarina.Types; use Ocarina.Types;
with Ocarina.Utils; use Ocarina.Utils; with Ocarina.Utils; use Ocarina.Utils;
with Ocarina.Lmp; use Ocarina.Lmp; with Ocarina.Lmp; use Ocarina.Lmp;
...@@ -697,6 +698,7 @@ package body Ocarina.Python_Cmd is ...@@ -697,6 +698,7 @@ package body Ocarina.Python_Cmd is
Default_AADL_Version := Get_Default_AADL_Version; Default_AADL_Version := Get_Default_AADL_Version;
AADL_Version := Ocarina.AADL_V2; AADL_Version := Ocarina.AADL_V2;
Ocarina.Configuration.Init_Modules; Ocarina.Configuration.Init_Modules;
Errors.Use_Exception_To_Exit;
-- Initialize Python bindings -- Initialize Python bindings
Repo := Register_Scripts_And_Functions; Repo := Register_Scripts_And_Functions;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment