There is no definitive answer to this, only you know your own fortitudes and limits from your experience.
Review your goals for the race, are they still attainable, if not then change your race goals, have a plan B, C, D.
You will recover from disappointment and embarrassment as you learn to analyse what went wrong, perhaps overtraining, too much pressure at home or at work and then you can deal with it and move on.
We can suffer from race amnesia, you forget about the pain and the problems and as you stand around after the fact, clearheaded, you kick yourself thinking I could have/I should have. Remind yourself that in the moment you made the choices you needed to make at that time.