Using generic catch for error handling