Quantum catastrophes and ergodicity in the dynamics of bosonic Josephson junctions