Skip to content

Commit

Permalink
more error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Apr 4, 2023
1 parent 53ada05 commit 507f3e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/java/network/brightspots/rcv/DominionCvrReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ Map<String, Contest> getContests() {
// parse CVR JSON for records matching the specified contestId into CastVoteRecord objects and add
// them to the input list
// Populates precinctIds with all found precincts
void readCastVoteRecords(List<CastVoteRecord> castVoteRecords, String contestId, Set<String> precinctIds)
void readCastVoteRecords(List<CastVoteRecord> castVoteRecords,
String contestId, Set<String> precinctIds)
throws CvrParseException, UnrecognizedCandidatesException {
// read metadata files for precincts, precinct portions, contest, and candidates

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/network/brightspots/rcv/Tabulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,8 @@ private OvervoteDecision getOvervoteDecision(Set<String> candidateSet) {
// logs the results to audit log
// update tallyTransfers counts
private void recordSelectionForCastVoteRecord(
CastVoteRecord cvr, int currentRound, String selectedCandidate, String outcomeDescription) {
CastVoteRecord cvr, int currentRound,
String selectedCandidate, String outcomeDescription) throws TabulationAbortedException {
// update transfer counts (unless there's no value to transfer, which can happen if someone
// wins with a tally that exactly matches the winning threshold)
if (cvr.getFractionalTransferValue().signum() == 1) {
Expand All @@ -848,6 +849,7 @@ private void recordSelectionForCastVoteRecord(
if (precinctTallyTransfer == null) {
Logger.severe("Precinct \"%s\" is not among the %d known precincts.",
precinctName, precinctNames.size());
throw new TabulationAbortedException(false);
}
precinctTallyTransfer.addTransfer(
currentRound,
Expand Down Expand Up @@ -875,7 +877,8 @@ private void recordSelectionForCastVoteRecord(
// - exhaust cvrs if they should be exhausted for various reasons
// - assign cvrs to continuing candidates if they have been transferred or in the initial count
// returns a map of candidate ID to vote tallies for this round
private Map<String, BigDecimal> computeTalliesForRound(int currentRound) {
private Map<String, BigDecimal> computeTalliesForRound(int currentRound)
throws TabulationAbortedException {
Map<String, BigDecimal> roundTally = getNewTally();
Map<String, Map<String, BigDecimal>> roundTallyByPrecinct = new HashMap<>();
if (config.isTabulateByPrecinctEnabled()) {
Expand Down

0 comments on commit 507f3e0

Please sign in to comment.