As you have discovered, undefined alone is not an error, but using undefined as an array / object is an error.
x = {'a': { 'b': { 'c': { 'd': [1,2,3,4,5]} } } } ; try { j = xabce[3] } catch(e) { console.log(e); }
prints
[TypeError: Cannot read property '3' of undefined]
This tells me that try / catch can be used with your code to return an error code and, if desired, an error text (or just paste the error text into console.log, a database, or a local file).
In your case, it might look like this:
var CharacterID;
source share