diff options
author | Jedidiah Barber <contact@jedbarber.id.au> | 2021-11-07 16:22:28 +1300 |
---|---|---|
committer | Jedidiah Barber <contact@jedbarber.id.au> | 2021-11-07 16:22:28 +1300 |
commit | 876d3c9c05563993438c6c58ddeff1ad97c3106b (patch) | |
tree | 2da595988014324d822ceef3d8ed92e2810aaceb /src | |
parent | af4ee4a230f1124a4c10761740aa41404d21d4a8 (diff) |
Improved error message handling
Diffstat (limited to 'src')
-rw-r--r-- | src/deck_convert.adb | 21 | ||||
-rw-r--r-- | src/deck_io.adb | 2 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/deck_convert.adb b/src/deck_convert.adb index 7037944..70c7abf 100644 --- a/src/deck_convert.adb +++ b/src/deck_convert.adb @@ -4,6 +4,7 @@ with Ada.Characters.Latin_1, Ada.Characters.Handling, + Ada.Exceptions, GNAT.Command_Line, GNAT.Strings, Ada.Command_Line, @@ -177,7 +178,8 @@ begin Deck_Format := +(Charhand.To_Lower (Format_Arg.all)); end if; if Deck_Format /= "csv" and Deck_Format /= "fmd" then - Put_Line (Standard_Error, "Output deck format required. Valid options are CSV or FMD." & + Put_Line (Standard_Error, + "ERROR: Output deck format required. Valid options are CSV or FMD." & Latin.LF & Further_Help); ACom.Set_Exit_Status (ACom.Failure); return; @@ -185,14 +187,14 @@ begin if Input_Arg.all = "" then - Put_Line (Standard_Error, "File name of input deck was not provided." & + Put_Line (Standard_Error, "ERROR: File name of input deck was not provided." & Latin.LF & Further_Help); ACom.Set_Exit_Status (ACom.Failure); return; end if; Input_Name := +(Input_Arg.all); if not FD.Exists (-Input_Name) then - Put_Line (Standard_Error, "Input deck does not exist." & + Put_Line (Standard_Error, "ERROR: Input deck does not exist." & Latin.LF & Further_Help); ACom.Set_Exit_Status (ACom.Failure); return; @@ -200,14 +202,14 @@ begin if Output_Arg.all = "" then - Put_Line (Standard_Error, "Base file name for output deck was not provided." & + Put_Line (Standard_Error, "ERROR: Base file name for output deck was not provided." & Latin.LF & Further_Help); ACom.Set_Exit_Status (ACom.Failure); return; end if; Output_Name := +(Output_Arg.all); if FD.Exists ((-Output_Name) & "." & (-Deck_Format)) and not Overwrite then - Put_Line (Standard_Error, "Output deck file name already exists." & + Put_Line (Standard_Error, "ERROR: Output deck file name already exists." & Latin.LF & Further_Help); ACom.Set_Exit_Status (ACom.Failure); return; @@ -285,6 +287,15 @@ begin end; +exception + + + when Fail : FD.Name_Error => + Put_Line (Standard_Error, Latin.LF & "ERROR: " & Ada.Exceptions.Exception_Message (Fail) & + Latin.LF & Further_Help); + ACom.Set_Exit_Status (ACom.Failure); + + end Deck_Convert; diff --git a/src/deck_io.adb b/src/deck_io.adb index 2e2d1b4..9884cdc 100644 --- a/src/deck_io.adb +++ b/src/deck_io.adb @@ -473,7 +473,7 @@ package body Deck_IO is end if; end if; if FD.Exists (-Outdir) and not Overwrite then - raise FD.Name_Error with "output directory " & (-Outdir) & " already exists"; + raise FD.Name_Error with "media directory " & (-Outdir) & " already exists"; end if; TIO.Create (File_Handle, TIO.Out_File, -Outname); Entry_Size := Positive (Model_Maps.Element (C).Fields.Length); |