Common error handling with callbacks