To avoid death you may eat a cactus but not a euphorbia. To avoid an irritating meal don't eat the prickly bits of either.
Mostly it's the fruit of cacti that people eat, after carefully removing any spines.The dragon fruit, from the climbing cactus Hylocereus, is perhaps the best known in Australia and England.
But look out for strawberry cactus fruit, prickly apple, Barbados gooseberry, chilito, garambulo, pitayo and tuna...
I encountered the succulent rather than piscean tuna most recently in Gran Canaria but I know it's big in Mexico. And not only tuna fruit, but the flattened blade of the prickly pear (Opuntia), the nopale.
If you collect or purchase tuna, the fruit, pick the bright red (or yellow) ones and again remove all spines. If you've ever brushed up against an Opuntia you'll know that it's the tiny microscopic spines that are most irritating. You don't want these in your mouth. The seeds, however, are usually eaten with the tuna flesh or removed when making syrups, jams and liquor.
Now, if you've been concentrating on my blogs you'll know that cacti grow naturally in Americas and not in Africa. However you'll have gathered by my mention of Gran Canaria that cacti do grow (in cultivation or as weeds) in the 'Old World'.
What you want to avoid, generally, are the cacti-like plants growing naturally in the Old World. These are species of Euphorbia. I gather from Marina Welham's How Dangerous are Euphorbias? (and Others in the Family Euphorbiaceae) that autopsies from those who didn't avoid eating Euphorbias revealed that the poison euphorbon inflames and perforates the stomach and intestine wall.
Euphorbon has some practical uses, as a purgative, a treatment for skin lesions and cancers, and for painting the tips of poison arrows. You get the general idea. There are exceptions, as always. Euphorbia esculenta, for example, has a species name that means 'edible' and is apparently used for cattle feed in South Africa.
So what to do? You can't rely on the country of origin to separate cacti from euphorbs due to our habit of spreading species beyond their evolved range. You should certainly seek the help of a trained taxonomist - and pay them handsomely for their expertise. And once you are confident you have a cactus, and one that tastes nice, don't, whatever you do, eat the spines. That's just dumb.
Images: The Dragon Fruit is from breakfast in Vietnam a few years ago. The rest are from Gran Canaria and all but the last one feature cacti (except for a stray Euphorbia amongst the prickly pears in the landscape picture). The final image, is Euphorbia canariensis.