Add proper error handling for getAvailableTasks.