There are several things you could do. If it's possible you can try to backtrack - go back to the nearest spot where you can set up a tent (that's what I did when my Sim got tired halfway through the dungeon). Another option is to use the Skeleton Dust from the Merchant (if you have it) and teleport out of the dungeon.
If neither of those options are available to you, you can cheat your way out of your situation (if not doing a Dynasty/Challenge). First try MoveObjects on and see if you can place a tent somewhere now. If that fails you could always resetSim to get out of the dungeon.
There is one last option, but I'm not 100% sure about it. If your Sim is too tired, they will pass out and your energy bar will go up. I'm just not sure if that will increase your energy level enough to go to a place where you can rest properly.
I hope this was able to help you.