Prevent endless loop on invalid collection type

http://jsfiddle.net/4B5Ra/1/ indicates that throwing an error in window.onerror leads to an endless loop. So instead of throwing an error in sendMessage() throw it on initialize.