/ src / cli / ct_errors.adb
ct_errors.adb
 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  package body CT_Errors is
 6  
 7     function Exit_Code_For (Category : Error_Category)
 8       return Ada.Command_Line.Exit_Status
 9     is
10     begin
11        case Category is
12           when Cat_Hash_Mismatch     => return Exit_Hash_Mismatch;
13           when Cat_Signature_Invalid => return Exit_Signature_Invalid;
14           when Cat_Key_Not_Trusted   => return Exit_Key_Not_Trusted;
15           when Cat_Policy_Rejection  => return Exit_Policy_Rejection;
16           when Cat_Missing_Attestation => return Exit_Missing_Attestation;
17           when Cat_Malformed_Bundle  => return Exit_Malformed_Bundle;
18           when Cat_IO_Error          => return Exit_IO_Error;
19           when Cat_Network_Error     => return Exit_Network_Error;
20        end case;
21     end Exit_Code_For;
22  
23     function Category_Name (Category : Error_Category) return String is
24     begin
25        case Category is
26           when Cat_Hash_Mismatch     => return "hash mismatch";
27           when Cat_Signature_Invalid => return "signature invalid";
28           when Cat_Key_Not_Trusted   => return "key not trusted";
29           when Cat_Policy_Rejection  => return "policy rejection";
30           when Cat_Missing_Attestation => return "missing attestation";
31           when Cat_Malformed_Bundle  => return "malformed bundle";
32           when Cat_IO_Error          => return "I/O error";
33           when Cat_Network_Error     => return "network error";
34        end case;
35     end Category_Name;
36  
37  end CT_Errors;