abstract out error handling for callback a bit