And so, being a failure is being trapped in the mind, right?
To think of yourself as a "failure" is to identify with it. So yes, that is being trapped in the mind. Rather than think that way acknowledge that a goal hasn't been met and leave it at that. Leave out all labels and judgments about it. Continue to work toward the goal if you want but without investing any belief that it will somehow "complete" you or make you more whole by reaching that goal. You are already whole, though you may not recognize this.
Consider what happens when goals are met. For a time there is satisfaction, but inevitably there will be another goal to strive for. Why? Because ego is always looking for completion outside itself, but it will never find lasting satisfaction. What isn't recognized is that beneath the ego wholeness and completeness are already here, but the constant striving of ego blocks the seeing of this completeness. This is what keeps people on an endless quest for happiness.
They'll look for that happiness in many ways: through religion, philosophy, power, position, material possession, knowledge and on and on. In other words, they look to the world of form, to add something to their current conception of where happiness can be found - that is all to meet a mental idea that has been accepted as true.
If people would look for the formless reality of what they are instead they would find wholeness. That wholeness is inherently peaceful. There is nothing that has to be added to be what you already are in reality, beyond ideas that only exist in the mind.