You’ll occasionally get errors downloading apps or updates from the App Store that are rather vague and difficult to fix.
Errors like Xcode failed to download. Use the Purchases page to try again or even less helpful An Error Has Occurred.
Fortunately there’s a simple fix for most of these errors, despite what originally caused them – reset the App Store app.
Quit the App Store and then in Terminal type in:
defaults write com.apple.appstore ShowDebugMenu -bool true
Then, launch the App Store and go to the newly visible Debug menu and select Reset Application
Quit and relaunch the App Store just to be sure and try downloading again.