added onerror callback throws exception if no callback defined