diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 4aacfea6..f898eb42 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -104,6 +104,13 @@ public void Alert(string type, string contents){ MessageBox.Show(contents, Program.BrandName+" Browser Message", MessageBoxButtons.OK, icon); } + public void CrashDebug(string message){ + #if DEBUG + Log(message); + System.Diagnostics.Debugger.Break(); + #endif + } + public void Log(string data){ System.Diagnostics.Debug.WriteLine(data); } diff --git a/Resources/Scripts/code.js b/Resources/Scripts/code.js index 80e04dd6..79fa04c6 100644 --- a/Resources/Scripts/code.js +++ b/Resources/Scripts/code.js @@ -62,6 +62,22 @@ }; }; + // + // Function: Returns true if an object has a specified property, otherwise returns false without throwing an error. + // + var ensurePropertyExists = function(obj, ...chain){ + for(var index = 0; index < chain.length; index++){ + if (!obj.hasOwnProperty(chain[index])){ + $TD.crashDebug("Missing property "+chain[index]+" in chain [obj]."+chain.join(".")); + return false; + } + + obj = obj[chain[index]]; + } + + return true; + }; + // // Function: Retrieves a property of an element with a specified class. //