What's causing iTunes to randomly display a 4002 error?
I got rid of this pesky error by


turning iTunes Match off
quit iTunes
launch iTunes
turn iTunes Match on


The first time iTunes complained with error 5002 during Match startup, but then it worked.