Changeset 6d8e1ab


Ignore:
Timestamp:
Aug 31, 2021, 1:49:10 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
Children:
a0d6987
Parents:
cac1d52
git-author:
Jacob Prud'homme <jafprudhomme@…> (08/06/21 22:05:11)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:10)
Message:

Improved EHM code

Added more exceptions, and removed forced exits (end users should handle this)

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    rcac1d52 r6d8e1ab  
    99
    1010
     11static vtable(Parse_Failure) Parse_Failure_vt;
     12
     13void ?{}( Parse_Failure & this ) with ( this ) {
     14        virtual_table = &Parse_Failure_vt;
     15}
     16
     17static vtable(Unknown_Config_Format) Unknown_Config_Format_vt;
     18
     19void ?{}( Unknown_Config_Format & this ) with ( this ) {
     20        virtual_table = &Unknown_Config_Format_vt;
     21}
     22
    1123static vtable(Validation_Failure) Validation_Failure_vt;
    1224
    13 void ?{}( Validation_Failure & this, config_entry & entry ) with ( entry ) {
    14         this.virtual_table = &Validation_Failure_vt;
    15         this.key = key;
    16         this.variable = variable;
     25void ?{}( Validation_Failure & this ) with ( this ) {
     26        virtual_table = &Validation_Failure_vt;
    1727}
    1828
     
    91101        } catch( Open_Failure * ex; ex->istream == &in ) {
    92102                delete( kv_pairs );
    93                 exit | "Error: could not open input file '" | config_file | "'";
     103                serr | "Error: could not open input file '" | config_file | "'";
     104                throw *ex;
    94105                // HERE (unfreed storage)
    95106        } // try
     
    106117                        kv_pairs = parse_tabular_config_format( config_file, num_entries );
    107118                default:
    108                         exit | "Error: config file format " | format | " is not supported";
     119                        serr | "Error: config file format " | format | " is not supported";
     120                        throw (Unknown_Config_Format){};
    109121        }
    110122
     
    125137                                        if ( !entries[j].validate( entries[j].variable ) ) {
    126138                                                delete( kv_pairs );
    127                                                 throw (Validation_Failure){ entries[j] };
     139                                                serr | "Error: config value at key '" | entries[j].key | "' did not pass validation";
     140                                                throw (Validation_Failure){};
    128141                                        }
    129142                                }
     
    132145                        }
    133146
    134                         serr | "Value '" | src_value | "' for key '" | src_key | "' could not be parsed";
     147                        delete( kv_pairs );
     148                        serr | "Error: value '" | src_value | "' for key '" | src_key | "' could not be parsed";
     149                        throw (Parse_Failure){};
    135150                }
    136151        }
  • libcfa/src/parseconfig.hfa

    rcac1d52 r6d8e1ab  
    5656
    5757
    58 exception Validation_Failure {
    59         const char * key;
    60         void * variable;
    61 };
     58exception Parse_Failure {};
    6259
    63 void ?{}( Validation_Failure & this, config_entry & entry );
     60void ?{}( Parse_Failure & this );
     61
     62exception Unknown_Config_Format {};
     63
     64void ?{}( Unknown_Config_Format & this );
     65
     66exception Validation_Failure {};
     67
     68void ?{}( Validation_Failure & this );
    6469
    6570
Note: See TracChangeset for help on using the changeset viewer.