In Psalm 139:23 David asks: “Search me, O God, and know my heart.” Then in :24 he prays: “and see if there be any hurtful way in me.” “Hurtful way” here is literally, “way of pain.” Our sinful, or ungodly ways, are “hurtful”, “painful” to ourselves and to others.
They are not merely violations of some arbitrary rules which God decided to give us. He gave us His commands because they are best for us. He wants us to worship and trust Him because He designed us to do that and it is healthy for us. When we do not trust Him, and fall into anxiety (:23) or when we violate His commandments, we bring pain and harm upon ourselves and others.
That is why David prays here: “See if there be any hurtful way in me.” There are undoubtedly hurtful, painful ways yet lodged in each of us. Our anxieties bring untold physical, emotional and spiritual harm upon ourselves. Our lies and hurtful words cause pain to others. And so on with countless examples of hurt which results from our sin. The deception is in believing that these ungodly ways are actually better for us, and will somehow bring us more pleasure than obeying God. They won’t. They are just what David calls them here: “hurtful”; “painful.” And each of us would do well to follow David’s example and ask God to search us and cleanse us from them.