Jailed: Man, 21, got text asking for drugs as he was being arrested
A man being arrested by police received a text message asking him if he had any drugs, a court heard.
A senior judge said that people who supplied Class A drugs had to go to prison.
At Mold Crown Court, Ryan Andrews, 21, who was arrested in High Street, Newtown, was sentenced to two-and-a-half years' youth detention after he admitted possessing MBMA and Class B cannabis, with intent to supply.
Presiding judge for Wales, Judge Eleri Rees, was told that the arrest was 15 months ago and that he had completely changed his lifestyle since then.
But the judge said: "Those who deal in Class A drugs go to prison. It is as simple as that."
The offences occurred when he was 20 and he would be given credit for his guilty pleas, she said. But he was found to have a significant amount of cash and text messages made it clear that he had embarked upon being a street dealer, playing a significant role.
David Mainstone, prosecuting, said that Andrews, of Croesawdy, Newtown, was arrested on the night of December 2014 in the town centre.
He was found to have £400 in cash on him and while he was being arrested his phone lit up and a text was received, asking "have you got any green?".
The defendant was searched, nothing was found, but there was a strong smell of cannabis on him.
As he was about to be handcuffed, he ran off and while in an alleyway was seen to take something out of his waistband and throw it under a car.
When recovered it was found to be cannabis.
WThe prosecutor said that when his home was searched police found 36 tablets which contained MDMA and a further £500 in cash.
When his mobile phone was examined, further incriminating text messages were found indicating that he was a street seller.
Myles Wilson, defending, said that his client had no previous convictions for drug supply.
He was a heavy drug user himself at the time. But his life was a lot different now.
He was no longer using drugs, he had formed a stable relationship with a partner and he had a job offer.
The defendant had been dealing drugs to a small number of friends, ten to 12 people.
He was quite vulnerable and he asked the judge to take an exceptional course and go outside the sentencing guidelines
The offences dated back 15 months which was a long time in the life of a young man.
There were real signs that he had got his life back on track, Mr Wilson explained.