The only way to avoid it is make sure the updated tileset is saved/exported before the map is saved, especially if you just added some tiles. I'm assuming you're using the default editor; maybe Radnen's editor has better error messages for this situation?
I believe Radnen's editor always saves the tilesets separately, so it can't happen? Not sure though, haven't used Radnen's map editor in a while...