Why does this throw an exception, but the catch blocks below just swallow their errors?