Loading ...
Sorry, an error occurred while loading the content.

Re: Error reporting in JSLint/ADSafe

Expand Messages
  • Douglas Crockford
    ... Please let me see your suggestions.
    Message 1 of 3 , May 10, 2010
    View Source
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "adam.kumpf" <adam.kumpf@...> wrote:
      > As a developer, I use the console.log() function (or ADSAFE.log() internal to an adsafe widget) frequently to debug my code.
      >
      > I've noticed that when there is an error within an ADSAFE widget, the console reads "uncaught exception: [object Object]" and cannot be inspected further.
      >
      > Since try/catch blocks seem to be discouraged within an ADSafe widget, what do you suggest the best way to report the details of those errors are to developers? I've found that it is sufficient for my work to simply add ADSAFE.log(e) to the three catch blocks within the adsafe.js code (which displays the full contents of the error object so that it can be inspected). Is this something that could (should?) go into the master version of adsafe.js?


      Please let me see your suggestions.
    • adam.kumpf
      ... Hi Doug, I added the ADSAFE.log() call to all three try/catch blocks. The most notable of which was when calling the supplied function: try { f(dom,
      Message 2 of 3 , May 10, 2010
      View Source
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
        >
        > --- In jslint_com@yahoogroups.com, "adam.kumpf" <adam.kumpf@> wrote:
        > > As a developer, I use the console.log() function (or ADSAFE.log() internal to an adsafe widget) frequently to debug my code.
        > >
        > > I've noticed that when there is an error within an ADSAFE widget, the console reads "uncaught exception: [object Object]" and cannot be inspected further.
        > >
        > > Since try/catch blocks seem to be discouraged within an ADSafe widget, what do you suggest the best way to report the details of those errors are to developers? I've found that it is sufficient for my work to simply add ADSAFE.log(e) to the three catch blocks within the adsafe.js code (which displays the full contents of the error object so that it can be inspected). Is this something that could (should?) go into the master version of adsafe.js?
        >
        >
        > Please let me see your suggestions.
        >


        Hi Doug,

        I added the ADSAFE.log() call to all three try/catch blocks. The most notable of which was when calling the supplied function:


        try {
        f(dom, adsafe_lib);
        } catch (e) {
        ADSAFE.log(e); // print error object for further inspection.
        return error();
        }


        There are two other places as well where the catch was ignored. I added the same line there as well:


        } catch (ignore) {
        ADSAFE.log(ignore);
        }


        Another way (which may make more sense) would be to add the ADSAFE.log() call in the error() function before throwing the exception. This is probably the way to go since it doesn't string the error output over three different places:


        function error(message) {
        ADSAFE.log("ADsafe error: " + (message || "ADsafe violation."));
        throw {
        name: "ADsafe",
        message: message || "ADsafe violation."
        };
        }


        Best,
        Adam
      Your message has been successfully submitted and would be delivered to recipients shortly.