diff --git a/read.cpp b/read.cpp index d60a08e3..2d9b8f29 100644 --- a/read.cpp +++ b/read.cpp @@ -363,10 +363,11 @@ std::unordered_map read_custom_cards(Cards& all_cards, const } unsigned num_line(0); cards_file.exceptions(std::ifstream::badbit); - try + + while(cards_file && !cards_file.eof()) { - while(cards_file && !cards_file.eof()) - { + try + { std::string card_spec; getline(cards_file, card_spec); trim(card_spec); @@ -379,23 +380,23 @@ std::unordered_map read_custom_cards(Cards& all_cards, const char mark{0}; parse_card_spec(all_cards, card_spec, card_id, card_num, num_sign, mark); cards[card_id] = card_num; - } - } - catch (std::exception& e) - { - if (abort_on_missing) - { - throw e; - } - else - { - std::cerr << "Exception while parsing the custom cards file " << filename; - if (num_line > 0) - { - std::cerr << " at line " << num_line; - } - std::cerr << ": " << e.what() << ".\n"; - } + } + catch (std::exception& e) + { + if (abort_on_missing) + { + throw e; + } + else + { + std::cerr << "Exception while parsing the custom cards file " << filename; + if (num_line > 0) + { + std::cerr << " at line " << num_line; + } + std::cerr << ": " << e.what() << ".\n"; + } + } } return cards; }