I have found this advice from Nick Tumminello to be an invaluable approach when I work with clients who have joint issues with shoulders, low backs and knees.
The idea is that you take an exercise and look at ways to modify or regress is so it causes minimal risk to someone and still allows them to train without causing further injury to that area.
If it is an injury, working in the pain free range of motion allows the tissues of that area to heal up in an unguarded state whereas if you keep trying to work through that injury it takes a lot longer to heal up or makes it worse to the point you have to stop anyway.
If it is an issue with the joints, then being able to work out whilst keeping pain free can make a big difference to how you feel and your enjoyment of working out.
Here are a few modification examples:
Reduce the range of motion. For example, if squatting to parallel irritates your knees but squatting to just above parallel doesn't, keep just above parallel.
If you have low back issues, setting the chest support closer to the machine so you don't have to stretch or rotate to reach the handles can save over stretching your back.
Changing hand or foot positions. Exercises such as shoulder presses and chest presses can irritate the shoulder joint when the palms are in a pronated position (palms facing down or away from the body). Switching to a neutral grip (where palms are facing) is a more shoulder friendly option.
Something I've recently been learning about and using with clients is how foot positions affect the range of motion when doing squats and deadlifts and make the movements feel easier and more free.
Switching exercises to different equipment. For example, switching from machines to free weights (barbells, dumbbells, kettlebells), from barbells to dumbbells, from machines to cable exercises, from free weights to resistance bands etc. These can be used to make exercises feel a lot more comfortable on a joint.
Two good examples to highlight this: I had someone come to me who had pretty much been using nothing but resistance machines and found they kept causing pain in her wrists, elbows and shoulders. I switched her from resistance machines to doing the same exercises with dumbbells and there was no more pain.
Another time, I was working with someone who had wrist / thumb joint issues so holding weights would often cause a lot of pain. On some exercises I played around with the grip to reduce the pain - something as simple as switching from a straight bar to an EZ bar. I then used a heavy duty ankle strap on his wrist in conjunction with resistance bands to take his grip out completely for some exercises and he was able to do them pain free.
So if you're doing an exercise and find it's irritating a joint and causing pain, try playing with some of these variations to see if that makes the exercise more suitable for you.
This is my, mostly, Personal Trainer musings and information which I hope you'll find helpful!