tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Callback hook for errors #134

Open tmedwards opened 3 years ago

tmedwards commented 3 years ago

Is your feature request related to a problem? It would be nice to be able to hook into SugarCube's error handling process.

Describe the solution you'd like. A callback property attached to the Config object that's passed the relevant error instance/details upon error—or maybe a copy.

BawdyInkSlinger commented 3 years ago

I am trying to trigger a line of JavaScript if my page errors no matter what the reason and per my googling, the way of doing that is to run this code:

window.onerror = function(message, source, lineno, colno, error) { 
    console.log("window.onerror", message);
  };

But if an error happens before that, this won't run I was just about to do this as a postprocessing step: https://stackoverflow.com/a/58265036/61624