Throw exceptions for better debugging of saved games with missing mods (#2388)

* Throw exceptions for better debugging of saved games with missing mods

* Close buttons are added
This commit is contained in:
Jack Rainy 2020-04-12 14:40:17 +03:00 committed by GitHub
parent 6fa22a92a1
commit 65b7927df6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View file

@ -210,7 +210,8 @@ class CityConstructions {
//region state changing functions //region state changing functions
fun setTransients(){ fun setTransients(){
builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getRuleset().buildings[it]!! }) builtBuildingObjects = ArrayList(builtBuildings.map { cityInfo.getRuleset().buildings[it]
?: throw java.lang.Exception("Building $it is not found!")})
} }
fun addProductionPoints(productionToAdd: Int) { fun addProductionPoints(productionToAdd: Int) {

View file

@ -338,7 +338,8 @@ class CivilizationInfo {
* And if they civs on't yet know who they are then they don;t know if they're barbarians =\ * And if they civs on't yet know who they are then they don;t know if they're barbarians =\
* */ * */
fun setNationTransient(){ fun setNationTransient(){
nation = gameInfo.ruleSet.nations[civName]!! nation = gameInfo.ruleSet.nations[civName]
?: throw java.lang.Exception("Nation $civName is not found!")
} }
fun setTransients() { fun setTransients() {

View file

@ -307,7 +307,8 @@ class MapUnit {
fun setTransients(ruleset: Ruleset) { fun setTransients(ruleset: Ruleset) {
promotions.unit=this promotions.unit=this
mapUnitAction?.unit = this mapUnitAction?.unit = this
baseUnit=ruleset.units[name]!! baseUnit=ruleset.units[name]
?: throw java.lang.Exception("Unit $name is not found!")
updateUniques() updateUniques()
} }

View file

@ -42,11 +42,13 @@ class LoadGameScreen : PickerScreen() {
if (ex is UncivShowableException && ex.localizedMessage != null) { if (ex is UncivShowableException && ex.localizedMessage != null) {
// thrown exceptions are our own tests and can be shown to the user // thrown exceptions are our own tests and can be shown to the user
cantLoadGamePopup.addGoodSizedLabel(ex.localizedMessage).row() cantLoadGamePopup.addGoodSizedLabel(ex.localizedMessage).row()
cantLoadGamePopup.addCloseButton()
cantLoadGamePopup.open() cantLoadGamePopup.open()
} else { } else {
cantLoadGamePopup.addGoodSizedLabel("If you could copy your game data (\"Copy saved game to clipboard\" - ").row() cantLoadGamePopup.addGoodSizedLabel("If you could copy your game data (\"Copy saved game to clipboard\" - ").row()
cantLoadGamePopup.addGoodSizedLabel(" paste into an email to yairm210@hotmail.com)").row() cantLoadGamePopup.addGoodSizedLabel(" paste into an email to yairm210@hotmail.com)").row()
cantLoadGamePopup.addGoodSizedLabel("I could maybe help you figure out what went wrong, since this isn't supposed to happen!").row() cantLoadGamePopup.addGoodSizedLabel("I could maybe help you figure out what went wrong, since this isn't supposed to happen!").row()
cantLoadGamePopup.addCloseButton()
cantLoadGamePopup.open() cantLoadGamePopup.open()
ex.printStackTrace() ex.printStackTrace()
} }