Changeset dcf792a


Ignore:
Timestamp:
Aug 31, 2021, 11:35:29 AM (5 months ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
jacob/cs343-translation, master
Children:
a75cd3d
Parents:
3be4078
Message:

Added more information to exceptions

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r3be4078 rdcf792a  
    1111static vtable(Missing_Config_Entries) Missing_Config_Entries_vt;
    1212
    13 void ?{}( Missing_Config_Entries & this, unsigned int num_missing ) with ( this ) {
    14         virtual_table = &Missing_Config_Entries_vt;
    15         missing = num_missing;
    16 }
     13void ?{}( Missing_Config_Entries & this, unsigned int num_missing ) {
     14        this.virtual_table = &Missing_Config_Entries_vt;
     15        this.num_missing = num_missing;
     16}
     17
    1718
    1819static vtable(Parse_Failure) Parse_Failure_vt;
    1920
    20 void ?{}( Parse_Failure & this ) with ( this ) {
    21         virtual_table = &Parse_Failure_vt;
    22 }
     21void ?{}( Parse_Failure & this, char * failed_key, char * failed_value ) {
     22        this.virtual_table = &Parse_Failure_vt;
     23
     24        this.failed_key = alloc( strlen( failed_key ) );
     25        this.failed_value = alloc( strlen( failed_value ) );
     26        strcpy( this.failed_key, failed_key );
     27        strcpy( this.failed_value, failed_value );
     28}
     29
     30void ^?{}( Parse_Failure & this ) with ( this ) {
     31        free( failed_key );
     32        free( failed_value );
     33}
     34
    2335
    2436static vtable(Validation_Failure) Validation_Failure_vt;
    2537
    26 void ?{}( Validation_Failure & this ) with ( this ) {
    27         virtual_table = &Validation_Failure_vt;
     38void ?{}( Validation_Failure & this, char * failed_key, char * failed_value ) {
     39        this.virtual_table = &Validation_Failure_vt;
     40
     41        this.failed_key = alloc( strlen( failed_key ) );
     42        this.failed_value = alloc( strlen( failed_value ) );
     43        strcpy( this.failed_key, failed_key );
     44        strcpy( this.failed_value, failed_value );
     45}
     46
     47void ^?{}( Validation_Failure & this ) with ( this ) {
     48        free( failed_key );
     49        free( failed_value );
     50}
    2851}
    2952
     
    128151                        // Parse the data
    129152                        if ( !entries[j].parse( src_value, entries[j].variable ) ) {
     153                                Parse_Failure * ex = new( src_key, src_value );
    130154                                delete( kv_pairs );
    131                                 throw (Parse_Failure){};
     155                                throw *ex;
    132156                        }
    133157
    134158                        // Validate the data
    135159                        if ( !entries[j].validate( entries[j].variable ) ) {
     160                                Validation_Failure * ex = new( src_key, src_value );
    136161                                delete( kv_pairs );
    137                                 throw (Validation_Failure){};
     162                                throw *ex;
    138163                        }
    139164
  • libcfa/src/parseconfig.hfa

    r3be4078 rdcf792a  
    5959
    6060exception Missing_Config_Entries {
    61         unsigned int missing;
     61        unsigned int num_missing;
    6262};
    6363
    6464void ?{}( Missing_Config_Entries & this );
    6565
    66 exception Parse_Failure {};
     66exception Parse_Failure {
     67        * char failed_key;
     68        * char failed_value;
     69};
    6770
    6871void ?{}( Parse_Failure & this );
    6972
    70 exception Validation_Failure {};
     73exception Validation_Failure {
     74        * char failed_key;
     75        * char failed_value;
     76};
    7177
    7278void ?{}( Validation_Failure & this );
Note: See TracChangeset for help on using the changeset viewer.