Better Crashes (RoG compatible) 1.0


2 Screenshots

About This File

Improves the information shown in game crashes by displaying information about the entity that triggered it.

Disclaimer: This mod is primarily meant for other modders. While its use is simple (since it simply needs to be enabled) and the information it presents might help tracking down the cause of bugs even in vanilla Don't Starve, the discussion below, explaining what the presented information means, assumes some level of familiarity with the inner workings of Don't Starve.

Whenever a crash occurs, this mod will attempt to find the entity "responsible" for it and show a set of information about it, in order to help to track down the root cause of the issue. Scenarios where the entity is found include crashes triggered within prefab files, components, stategraphs and brains*.

The following information about the entity is shown:

  • Its number (its GUID) and its prefab name;
  • Its variable name, within the function that triggered the crash (this may be an "indirect" variable name, such as self.inst);
  • Whether the entity is valid;
  • Whether the entity is in limbo (i.e., whether it was removed from the scene);
  • Whether it's asleep (in the sense that it is not active);
  • How long it's been alive (i.e., how long it has been since it was spawned, noting that reloading a save respawns all entities);
  • Its position (as world coordinates);
  • Its distance to the player.

In the error screen, the entity information is presented on the right of the stack trace (hence dividing the usual text region into two columns). See the attached screenshot for an example (obtained by replicating this bug with the mod enabled). In the same example, the following is printed in log.txt:

scripts/components/propagator.lua:109: attempt to index field 'instcomponents' (a nil value)Entity information:	entity: [108621 - willowfire]	variable name: self.inst	valid: true	in limbo: false	asleep: false	time alive (seconds): 1.10	position: (-164.92, -0.00, -207.38)	distance to player: : 7.55LUA ERROR stack traceback:        scripts/components/propagator.lua(109,1) in function 'OnUpdate'        scripts/components/propagator.lua(39,1) in function 'fn'        scripts/scheduler.lua(170,1) in function 'OnTick'        scripts/scheduler.lua(381,1) in function 'RunScheduler'        scripts/update.lua(87,1)        =(tail call) ?        =[C] in function 'xpcall'        ../mods/BetterCrashes/modmain.lua(160,1)LUA ERROR stack traceback:        =[C] in function 'error'        ../mods/BetterCrashes/modmain.lua(149,1)        =(tail call) ?scripts/frontend.lua(712,1) SCRIPT ERROR! Showing error screen	

Note that, unfortunately, usage of this mod causes two "LUA ERROR stack traceback" blocks to be printed per error (the second being a "continuation" of the first). This happens because for the mod to work it needs to catch an error and then rethrow it.

* The general condition is the following: the mod takes a look at the first parameter passed to the function that caused the crash (the "self" parameter, if any, counts as the first); if this parameter is an entity, this entity's information is displayed; otherwise, if this parameter is a table with an entity stored in its "inst" field, this entity's information is displayed. This convention is adopted because most (all?) function in the Don't Starve code that operate on an entity either receive that entity as its first argument, or receive a "self" first parameter which stores the entity in self.inst.




User Feedback

Recommended Comments

Thanks, i needed this. Because i have so many mods, when it crashes, and doesent present which mod caused it, i have to spend all of my Saturday enabling and disabling mods to see which one is causing the problem. You have just saved me from a lot of late night headaches.

  • Like 1

Share this comment


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now