added error event listeners

should prevent most crashes