replaced "throw" with emitted error