handle exceptions in callbacks