https://bugzilla.wikimedia.org/show_bug.cgi?id=27890

           Summary: Create a way to throw Warnings and Errors with proper
                    tracing
           Product: MediaWiki
           Version: 1.18-svn
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: Normal
         Component: Resource Loader
        AssignedTo: krinklem...@gmail.com
        ReportedBy: krinklem...@gmail.com
                CC: roan.katt...@gmail.com, tpars...@wikimedia.org


If a native javascript method fails (eg. calling a member as a function on a
non-object) there's an error thrown:

  TypeError: Result of expression 'f.test' [undefined] is not a function. 
[test.js:2]

But when a custom error is thrown (ie. "MediaWiki DeprecatedWarning: Function
mw.legacy.sajax_init_object is deprecated" ) it will report no file/line number
to the console or in some cases the filename and line number where the throw
originates from, not where the function was called.

So the goal of this bug is to end up with something like:

-- short wrappers to avoid doing any throws directly in the code (would use or
do something like jQuery.error )
* mw.log (what it is now, simple dummy in production and console.log or
mw.console in debug for logging messages)
* mw.log.error and mw.log.warning for throwing stuff
* mw.log.deprecated calls mw.log.warning with some magic stuff to know what was
called and where it comes from

-- example of where it is defined
mw.legacy.sajax_init_object : function() {
 mw.log.deprecated();

 /* stuff */

}

-- example of where it would be triggered
function myGadget(){
  var path = '...';
  var xhttp = mw.legacy.sajax_init_object()
  /* etc. stuff */
  var foobar = getStuff();
  mw.util.addPortletLink( foobar );
}

-- example of console output
{X} MWDeprecatedWarning: Use of sajax_init_object is deprecated [mygadget.js:3]
{X} MWSyntaxError: addPortletLink requires at least 3 arguments, 2 given
[mygadget:49]



Links of interest:
* https://github.com/emwendelin/javascript-stacktrace/blob/master/stacktrace.js
* http://eriwen.com/javascript/stacktrace-update/

--
Krinkle

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to