Forum Discussion
Why does developer visual work in one report but not in another?
Hi Daniel
Where do I put the logExceptions code? It throws an error wherever I try.
I have tried to post code in reply to you several times but either my replies get removed (marked as spam!) or the code itself is too long.
Thanks
Emma
Hi emmasaunders,
If you're referring to this article, I've never found it particularly handy as it doesn't work for the latest versions of the SDK. There is supposedly a working version in the Git repo issues but I haven't perservered with it so YMMV.
Personally, I just use a simple try/catch block with my code to quickly diagnose anything obvious:
public update(options: VisualUpdateOptions) {
/** Handle main update flow */
try {
console.log('Visual update', options);
this.settings = Visual.parseSettings(options && options.dataViews && options.dataViews[0]);
/** My actual code goes here ... */
console.log('Finished rendering');
return;
} catch(e) {
console.log(`Rendering failed: ${e}`);
/** Any user-facing stuff in here */
}
}In my production code I use something similar but create a simple set of static methods for logging, based on a global flag that I set to indicate whether I'm developing or not. That way, I can put telemetry all through my code that I can use to quickly debug when I'm developing, and then set this flag to false when I publish so that end-users aren't subjected to it.
Regarding sharing code, either a source repo link (e.g. Github) or a public OneDrive (or similar) share is usually the better way to get around file and forum limits. This way, we can attempt to reconstruct your entire project, incluing any NPM packages you might be using, just in case it's something there. See how you get on with the above to see if anything obvious falls out - if you want to forward on some code after that, feel free to try using one of the above methods, or feel free to PM me and I can provide you with an email address and we can arrange that way.
Good luck!
Daniel