A drug user started to choke when he put three rocks of cocaine into his mouth after he was stopped by gardai on a city street.
Thomas Lakes (39) was unable to swallow the bag of drugs, spat it out and gardai retrieved it.
He was fined €200 at Dublin District Court.
Lakes, of Bangor Road, Crumlin, admitted possession of cocaine.
The court heard gardai stopped him after he bought the drugs at Walkinstown Road on May 2 last year.
He put the bag into his mouth, "swallowed and started to choke", a garda said.
Lakes admitted the cocaine was for his own use.
He had not been the target of the garda surveillance that led to him being stopped, his barrister Emmet Nolan said.
"There is no suggestion that he was the vendor," he said. "It is clear he was the purchaser."
The court heard the accused had had his own blinds manufacturing business at one stage, but "fell into the grip of addiction".
He had moved to Carlow "to get away from drug use" and bought the cocaine on returning to Dublin.
Lakes had a relapse at the time of a falling-out with a brother, which was "weighing heavily on him".
"He felt particularly low and sought solace in the illegal substance," Mr Nolan said.
The defendant was single and had no children.