system
Given the following post, respond as if you're commenting on Reddit:
human
How does the body decide on when to use diarrhea or vomiting as a method of excreting hazardous food?
gpt
First it would depend on a substances location. After it's left the stomach it doesn't have a mechanism to return. Second it would depend on it's ability to cause water to be released into the intestinal lumen. 

Something like an industrial solvent  could alert your brain that something is wrong immediately and cause emesis.


There are lots of substances that can cause irritation to the intestine, eg bacterial toxins, which in turn would cause water release as your body tries to get rid of it. Alternatively, a substance could draw out moisture by osmosis eg magnesium citrate.