Handle and emit errors