Depends entirely on your intent. A perfectly measured chastity cage will fit nicely and prevents the penis from getting erect in the first place. No pain and no bad effects.
For S&M lovers there CAN be cages that hurts when the penis gets erect, tho this should be enjoyable in a way for pain seekers.