/ src / cli / ct_errors.ads
ct_errors.ads
 1  --  Cerro Torre CLI - Exit codes and error types
 2  --  SPDX-License-Identifier: MIT OR AGPL-3.0-or-later
 3  --  Palimpsest-Covenant: 1.0
 4  
 5  with Ada.Command_Line;
 6  
 7  package CT_Errors is
 8  
 9     --  Exit codes per spec/cli-ergonomics.adoc
10     --  Each exit code maps to a specific failure type for scripting
11  
12     Exit_Success          : constant Ada.Command_Line.Exit_Status := 0;
13     Exit_Hash_Mismatch    : constant Ada.Command_Line.Exit_Status := 1;
14     Exit_Signature_Invalid : constant Ada.Command_Line.Exit_Status := 2;
15     Exit_Key_Not_Trusted  : constant Ada.Command_Line.Exit_Status := 3;
16     Exit_Policy_Rejection : constant Ada.Command_Line.Exit_Status := 4;
17     Exit_Missing_Attestation : constant Ada.Command_Line.Exit_Status := 5;
18     Exit_Malformed_Bundle : constant Ada.Command_Line.Exit_Status := 10;
19     Exit_IO_Error         : constant Ada.Command_Line.Exit_Status := 11;
20     Exit_Network_Error    : constant Ada.Command_Line.Exit_Status := 12;
21  
22     --  General failure (usage error, not yet implemented, etc.)
23     Exit_General_Failure  : constant Ada.Command_Line.Exit_Status := 1;
24  
25     --  Error categories for message formatting
26     type Error_Category is
27       (Cat_Hash_Mismatch,
28        Cat_Signature_Invalid,
29        Cat_Key_Not_Trusted,
30        Cat_Policy_Rejection,
31        Cat_Missing_Attestation,
32        Cat_Malformed_Bundle,
33        Cat_IO_Error,
34        Cat_Network_Error);
35  
36     --  Get exit code for an error category
37     function Exit_Code_For (Category : Error_Category)
38       return Ada.Command_Line.Exit_Status;
39  
40     --  Get human-readable category name
41     function Category_Name (Category : Error_Category) return String;
42  
43  end CT_Errors;