An Ilkeston man who had already served time in jail was allowed to walk free from court after the judge said he was showing him an act of mercy.
James Whitworth, 30, of Wilmot Street, admitted two counts of threatening behaviour.
Derby Crown Court heard messages sent by Whitworth on Facebook were threatening to harm and even kill his ex-girlfriend Karen Winfield.
After muttering under his breath while in the dock, his honour Judge Robert Egbuna interrupted proceedings and found Whitworth in breach of contempt of court.
Prosecutor Hal Ewing said: “The threatening and abusive messages were sent to his former partner after they split up in September 2015.
“Karen has been really worried and it was only after the defendant was arrested for the threats that she said she felt safe. She has children and their safety is her number one priority.”
In mitigation, Dominic Shelley said: “This has been a highly emotive time for the defendant who has already served four months on remand.”
The judge issued a restraining order which prevents Whitworth from having direct or indirect contact with Ms Winfield, or attending within 100 metres of her home address.
In closing, Judge Egbuna said: “The messages you sent could have seen you serve a 12-month sentence, but as you have already served four months of an eight-month imprisonment, this will lead to your immediate release.
“See this as an act of mercy.
“Most other judges would have dealt with the contempt issues.
“The restraining order will be in place for as long as the court deems and if you break the order and have the misfortune of being in front of me again there will be no further acts of mercy.”