Jackmcbarn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/170648

Change subject: Set the correct error source from mw.html
......................................................................

Set the correct error source from mw.html

When mw.html errors, make the error message show that it's the caller's
fault rather than mw.html's fault.

Change-Id: Id8b28cbcf186bc3e0e5807ed48a1ec3a4c052357
---
M engines/LuaCommon/lualib/mw.html.lua
1 file changed, 15 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto 
refs/changes/48/170648/1

diff --git a/engines/LuaCommon/lualib/mw.html.lua 
b/engines/LuaCommon/lualib/mw.html.lua
index 26b8034..e634cf9 100644
--- a/engines/LuaCommon/lualib/mw.html.lua
+++ b/engines/LuaCommon/lualib/mw.html.lua
@@ -145,7 +145,7 @@
 -- @param builder
 methodtable.node = function( t, builder )
        if t.selfClosing then
-               error( "Self-closing tags can't have child nodes" )
+               error( "Self-closing tags can't have child nodes", 2 )
        end
 
        if builder then
@@ -159,7 +159,7 @@
        local vals = {...}
        for i = 1, #vals do
                if type( vals[i] ) ~= 'string' and type( vals[i] ) ~= 'number' 
then
-                       error( 'Invalid wikitext given: Must be either a string 
or a number' )
+                       error( 'Invalid wikitext given: Must be either a string 
or a number', 2 )
                end
 
                t:node( vals[i] )
@@ -204,7 +204,7 @@
 methodtable.attr = function( t, name, val )
        if type( name ) == 'table' then
                if val ~= nil then
-                       error( 'If a key->value table is given as first 
parameter, value must be left empty' )
+                       error( 'If a key->value table is given as first 
parameter, value must be left empty', 2 )
                end
 
                local callForTable = function()
@@ -214,17 +214,17 @@
                end
 
                if not pcall( callForTable ) then
-                       error( 'Invalid table given: Must be name (string) 
value (string|number) pairs' )
+                       error( 'Invalid table given: Must be name (string) 
value (string|number) pairs', 2 )
                end
 
                return t
        end
 
        if type( name ) ~= 'string' then
-               error( 'Invalid name given: The name must be a string' )
+               error( 'Invalid name given: The name must be a string', 2 )
        end
        if val ~= nil and type( val ) ~= 'string' and type( val ) ~= 'number' 
then
-               error( 'Invalid value given: The value must be either a string 
or a number' )
+               error( 'Invalid value given: The value must be either a string 
or a number', 2 )
        end
 
        -- if caller sets the style attribute explicitly, then replace all 
styles
@@ -235,7 +235,7 @@
        end
 
        if not isValidAttributeName( name ) then
-               error( "Invalid attribute name: " .. name )
+               error( "Invalid attribute name: " .. name, 2 )
        end
 
        local attr, i = getAttr( t, name )
@@ -262,7 +262,7 @@
        end
 
        if type( class ) ~= 'string' and type( class ) ~= 'number' then
-               error( 'Invalid class given: The name must be either a string 
or a number' )
+               error( 'Invalid class given: The name must be either a string 
or a number', 2 )
        end
 
        local attr = getAttr( t, 'class' )
@@ -282,7 +282,7 @@
 methodtable.css = function( t, name, val )
        if type( name ) == 'table' then
                if val ~= nil then
-                       error( 'If a key->value table is given as first 
parameter, value must be left empty' )
+                       error( 'If a key->value table is given as first 
parameter, value must be left empty', 2 )
                end
 
                local callForTable = function()
@@ -292,17 +292,17 @@
                end
 
                if not pcall( callForTable ) then
-                       error( 'Invalid table given: Must be name 
(string|number) value (string|number) pairs' )
+                       error( 'Invalid table given: Must be name 
(string|number) value (string|number) pairs', 2 )
                end
 
                return t
        end
 
        if type( name ) ~= 'string' and type( name ) ~= 'number' then
-               error( 'Invalid CSS given: The name must be either a string or 
a number' )
+               error( 'Invalid CSS given: The name must be either a string or 
a number', 2 )
        end
        if val ~= nil and type( val ) ~= 'string' and type( val ) ~= 'number' 
then
-               error( 'Invalid CSS given: The value must be either a string or 
a number' )
+               error( 'Invalid CSS given: The value must be either a string or 
a number', 2 )
        end
 
        for i, prop in ipairs( t.styles ) do
@@ -330,7 +330,7 @@
 methodtable.cssText = function( t, css )
        if css ~= nil then
                if type( css ) ~= 'string' and type( css ) ~= 'number' then
-                       error( 'Invalid CSS given: Must be either a string or a 
number' )
+                       error( 'Invalid CSS given: Must be either a string or a 
number', 2 )
                end
 
                table.insert( t.styles, css )
@@ -361,11 +361,11 @@
 function HtmlBuilder.create( tagName, args )
        if tagName ~= nil then
                if type( tagName ) ~= 'string' then
-                       error( "Tag name must be a string" )
+                       error( "Tag name must be a string", 2 )
                end
 
                if tagName ~= '' and not isValidTag( tagName ) then
-                       error( "Invalid tag name: " .. tagName )
+                       error( "Invalid tag name: " .. tagName, 2 )
                end
        end
 

-- 
To view, visit https://gerrit.wikimedia.org/r/170648
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id8b28cbcf186bc3e0e5807ed48a1ec3a4c052357
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <jackmcb...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to