Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: How to best track down errors?  (Read 2912 times)

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
How to best track down errors?
« on: November 25, 2014, 12:17:33 PM »

So I'm using Okims Ironclads mod. All well and good. But I made my own additions to it a few version ago (new faction with a few new ship, 1 new weapon and  new hull mod).
Now I'm positive I added everythig that's necessary, but I get this:

Code
4585 [Thread-5] ERROR com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO  - org.json.JSONException: Unterminated string at 157 [character 0 line 12]
org.json.JSONException: Unterminated string at 157 [character 0 line 12]
at org.json.JSONTokener.syntaxError(JSONTokener.java:423)
at org.json.JSONTokener.nextString(JSONTokener.java:249)
at org.json.JSONTokener.nextValue(JSONTokener.java:349)
at org.json.JSONObject.<init>(JSONObject.java:195)
at org.json.JSONTokener.nextValue(JSONTokener.java:352)
at org.json.JSONObject.<init>(JSONObject.java:210)
at org.json.JSONObject.<init>(JSONObject.java:311)
at com.fs.starfarer.loading.LoadingUtils.ô00000(Unknown Source)
at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
at com.fs.starfarer.loading.LoadingUtils.super(Unknown Source)
at com.fs.starfarer.loading.LoadingUtils.?00000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.ÖO0000(Unknown Source)
at com.fs.starfarer.loading.SpecStore.ö00000(Unknown Source)
at com.fs.starfarer.loading.void.super(Unknown Source)
at com.fs.A.oOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
at com.fs.starfarer.combat.O0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.super(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Where the hell do I even being to look?
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: How to best track down errors?
« Reply #1 on: November 25, 2014, 12:24:27 PM »

Look a line or two above that error to see which file was last loaded, as that's where the syntax error will be. It should look something like this:
Code
16918 [Thread-5] INFO  com.fs.starfarer.loading.LoadingUtils  - Loading JSON from [C:\Users\Rob\Programs\Starfarer\starsector-core\..\mods\Exigency\data\variants\exigency_destroyer_Skirmisher.variant]

I believe Starsector treats JSON files as one long line, so the "at 157" part of your error message means the mistake is at or before the 157th character in your JSON file (possibly excluding comments). Rather than count characters, you can just guess at the general area of the syntax error using that information (character 157 would probably be several lines down). Never mind that, looks like JSON errors actually do show line numbers (oops). It says it's at the beginning of line 12.

Since your error is an unterminated string, there are three things to be on the lookout for:
  • A missing quotation mark at the end of a line
  • Double quotation marks at the beginning of a line
  • A quotation mark inside of a string, which has to be escaped with \ to avoid being considered the end of that string. Proper use of an escape character would look like this: "In the four years since \"The Incident\", the system has quickly deteriorated as [...]"


Edit: added more information on tracking down that specific error.
Edit2: log reading comprehension fail.
« Last Edit: November 25, 2014, 12:59:34 PM by LazyWizard »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: How to best track down errors?
« Reply #2 on: November 26, 2014, 01:29:01 AM »

Thanks.

My modification did work flawlesly on older version of SS and Ironclads and I have been very careful in properly tweaking it for the new version.
Guess that no matter how big a modding experience you have, there's always more to learn  :P
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: How to best track down errors?
« Reply #3 on: November 26, 2014, 07:01:20 AM »

No luck.

I have:
4495 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [data.hullmods.ExtendedShieldEmitter]
above the error

Which is a file I haven't touched at all. Furthermore I have about a 50 other files loaded after the error. the very last file is:
6638 [Thread-8] INFO  com.fs.starfarer.loading.scripts.ScriptStore  - Class [com.fs.starfarer.api.impl.campaign.events.RecentUnrestEvent]

Again, a file I haven't touched.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: How to best track down errors?
« Reply #4 on: November 26, 2014, 11:56:18 AM »

Oops, I forgot to mention: the loading process is multi-threaded, so you need to look for the last file loaded in the same thread. So look for the last line before the crash that starts with [Thread-5]. :)

It might be faster to just click on the error and do a reverse-direction search from there for com.fs.starfarer.loading.LoadingUtils (CTRL+F, either 'find previous' or set direction to 'up' in most editors).


Good luck with your mod-mod! :)
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: How to best track down errors?
« Reply #5 on: November 26, 2014, 02:07:38 PM »

Yup. I managed to track it down. missing " in my faction file. I almost tracked down 2 more errors. Now facing a NULL error that seems to be caused by the "InfusedHull" hullmod

I  guess this code no longer works?



EDIT:

False alar.

Turns out it's this:

3709 [Thread-5] WARN  com.fs.starfarer.loading.ShipHullSpreadsheetLoader  - Ship hull [vns_phnh] from ship_data.csv not found in store

I don't get it. The hull is there, the variant is there, the wing is there.... Hhmmmmmm
« Last Edit: November 26, 2014, 02:24:05 PM by TrashMan »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: How to best track down errors?
« Reply #6 on: November 26, 2014, 02:35:05 PM »

YES. finally work.....crap.

hullmod.java failed compling at 99%

Can someone check WTF siwrong, it used to work before

Code
package data.hullmods;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;

import java.util.HashMap;
import java.util.Map;

public class InfusedHull extends BaseHullMod {

public static final float REPAIR_FRACTION = 1f;
public static final float REPAIR_BONUS = .99f;

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 5f);
mag.put(HullSize.FRIGATE, 1f);
mag.put(HullSize.DESTROYER, .75f);
mag.put(HullSize.CRUISER, .5f);
mag.put(HullSize.CAPITAL_SHIP, .25f);
}

public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getHullRepairRatePercentPerSecond().modifyFlat(id, (Float) mag.get(hullSize));
stats.getMaxHullRepairFraction().unmodify(id);
stats.getMaxHullRepairFraction().modifyFlat(id, REPAIR_FRACTION);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "1";// + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return ".75";// + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return ".5";// + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return ".25";// + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}
}


If I remove the hullmod, everything works. But I still need a working code
« Last Edit: November 26, 2014, 02:46:57 PM by TrashMan »
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1365
    • View Profile
    • GitHub Profile
Re: How to best track down errors?
« Reply #7 on: November 26, 2014, 03:03:33 PM »

Add an import for com.fs.starfarer.api.combat.BaseHullMod, and remove BaseHullMod.java from data/hullmods if it's present.



It's not an error, but you're also using some deprecated methods.

Code: java
		stats.getHullRepairRatePercentPerSecond().modifyFlat(id, (Float) mag.get(hullSize));
stats.getMaxHullRepairFraction().unmodify(id);
stats.getMaxHullRepairFraction().modifyFlat(id, REPAIR_FRACTION);
can be changed to
Code: java
		stats.getHullCombatRepairRatePercentPerSecond().modifyFlat(id, (Float) mag.get(hullSize));
stats.getMaxCombatHullRepairFraction().unmodify(id);
stats.getMaxCombatHullRepairFraction().modifyFlat(id, REPAIR_FRACTION);
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: How to best track down errors?
« Reply #8 on: November 27, 2014, 03:40:12 AM »

Thank you.
That was some swift help.

A bit of polishing and I'll update my mod  ;D
Logged