Fix error and exception handler