use correct iterator for conditional breaking

Array.forEach() is no bueno if you're looking to break out of the outer
function.

Also swapped console error logging for thrown errors.