To express delight that something went awfully wrong for someone (they might have had it coming to them or deserved it in someway, or you might dislike them). For example if an insult they used backfired.
'A thing of' is a very Irish way of describing an inanimate object, usually a container or packaging of sorts. Be it down to laziness, or actually not knowing the name of what the object is, this expression has many uses.