Changeset 4431


Ignore:
Timestamp:
Jan 21, 2015, 11:26:40 AM (4 years ago)
Author:
cameron
Message:

Throw exceptions in preference to exit(-1)

Location:
icGREP/icgrep-devel/icgrep
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r4397 r4431  
    1212#include <iostream>
    1313#include <unordered_map>
     14#include <stdexcept>
    1415#include "unicode_set.h"
    1516#include "PropertyAliases.h"
     
    5758       
    5859        UnicodeSet UnsupportedPropertyObject::GetCodepointSet(std::string value_spec) {
    59                 std::cerr << "Property " << UCD::property_full_name[the_property] << " unsupported.\n";
    60                 exit(-1);
     60                throw std::runtime_error("Property " + UCD::property_full_name[the_property] + " unsupported.");
    6161        }
    6262       
     
    8484                int property_enum_val = GetPropertyValueEnumCode(value_spec);
    8585                if (property_enum_val == -1) {
    86                         std::cerr << "Enumerated Property " << UCD::property_full_name[the_property] << ": unknown value: " << value_spec << ".\n";
    87                         exit(-1);
     86                        throw std::runtime_error("Enumerated Property " + UCD::property_full_name[the_property] +  ": unknown value: " + value_spec);
    8887                }
    8988                else {
    90                         std::cout << "Enumerated Property: " << UCD::property_full_name[the_property] << ", value: " << property_value_full_names[property_enum_val] << "(" << property_enum_val << ").\n";
     89                        //std::cout << "Enumerated Property: " << UCD::property_full_name[the_property] << ", value: " << property_value_full_names[property_enum_val] << "(" << property_enum_val << ").\n";
    9190                        return property_value_sets[property_enum_val];
    9291                }
     
    122121                        auto valit = Binary_ns::aliases_only_map.find(value_spec);
    123122                        if (valit == Binary_ns::aliases_only_map.end()) {
    124                                 std::cerr << "Binary property " << property_full_name[the_property] << ": bad value: " << value_spec << ".\n";
    125                                 exit(-1);
     123                                throw std::runtime_error("Binary Property " + UCD::property_full_name[the_property] +  ": bad value: " + value_spec);
    126124                        }
    127125                        else property_enum_val = valit->second;
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r4410 r4431  
    9696    }
    9797    else if (isa<CC>(re)) {
    98         std::cerr << "Shouldn't get here\n";
    99         exit(-1);
     98        throw std::runtime_error("icgrep internal error: unexpected CC object found in compileByteClasses.");
    10099    }
    101100}
  • icGREP/icgrep-devel/icgrep/compiler.cpp

    r4416 r4431  
    6666        catch (ParseFailure failure)
    6767        {
    68             std::cerr << "REGEX PARSING FAILURE: " << failure.what() << std::endl;
     68            std::cerr << "Regex parsing failure: " << failure.what() << std::endl;
    6969            std::cerr << regexps[i] << std::endl;
    7070            exit(1);
Note: See TracChangeset for help on using the changeset viewer.