Why not make this an IllegalArgumentException (or scala equivalent)? suggested by @mmlinford if (maxRecords > 0) { maxRecordsCopy = maxRecords;