From d74c81c2337ad162d71e21a6a83e7bc68c5eaf85 Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Sun, 13 Apr 2014 21:24:21 -0400 Subject: [PATCH] Add name to nosuchfunction and nosuchmodule errors When displaying a nosuchfunction or nosuchmodule error, include the name of the nonexistent function or module. Change-Id: I17fc2c68dc8267302a82eee3cb2c5df9b5a3c46c --- common/Hooks.php | 4 ++-- engines/LuaCommon/LuaCommon.php | 2 +- i18n/en.json | 4 ++-- i18n/qqq.json | 4 ++-- tests/engines/LuaCommon/luaParserTests.txt | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/Hooks.php b/common/Hooks.php index af4a5310..c16c109b 100644 --- a/common/Hooks.php +++ b/common/Hooks.php @@ -94,11 +94,11 @@ class ScribuntoHooks { $engine = Scribunto::getParserEngine( $parser ); $title = Title::makeTitleSafe( NS_MODULE, $moduleName ); if ( !$title || Scribunto::isDocPage( $title ) ) { - throw new ScribuntoException( 'scribunto-common-nosuchmodule' ); + throw new ScribuntoException( 'scribunto-common-nosuchmodule', array( 'args' => array( $moduleName ) ) ); } $module = $engine->fetchModuleFromParser( $title ); if ( !$module ) { - throw new ScribuntoException( 'scribunto-common-nosuchmodule' ); + throw new ScribuntoException( 'scribunto-common-nosuchmodule', array( 'args' => array( $moduleName ) ) ); } $functionName = trim( $frame->expand( $args[1] ) ); diff --git a/engines/LuaCommon/LuaCommon.php b/engines/LuaCommon/LuaCommon.php index 50b9584f..7e9e3871 100644 --- a/engines/LuaCommon/LuaCommon.php +++ b/engines/LuaCommon/LuaCommon.php @@ -666,7 +666,7 @@ class Scribunto_LuaModule extends ScribuntoModuleBase { public function invoke( $name, $frame ) { $exports = $this->execute(); if ( !isset( $exports[$name] ) ) { - throw $this->engine->newException( 'scribunto-common-nosuchfunction' ); + throw $this->engine->newException( 'scribunto-common-nosuchfunction', array( 'args' => array( $name ) ) ); } $result = $this->engine->executeFunctionChunk( $exports[$name], $frame ); diff --git a/i18n/en.json b/i18n/en.json index 114c53bf..2b64d998 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -25,9 +25,9 @@ "scribunto-console-cleared-session-lost": "The console state was cleared because the session data was lost.", "scribunto-common-error-category": "Pages with script errors", "scribunto-common-error-category-desc": "There was an error when processing the modules included on the page.", - "scribunto-common-nosuchmodule": "Script error: No such module.", + "scribunto-common-nosuchmodule": "Script error: No such module \"$2\".", "scribunto-common-nofunction": "Script error: You must specify a function to call.", - "scribunto-common-nosuchfunction": "Script error: The function you specified did not exist.", + "scribunto-common-nosuchfunction": "Script error: The function \"$2\" does not exist.", "scribunto-common-timeout": "The time allocated for running scripts has expired.", "scribunto-common-oom": "The amount of memory allowed for running scripts has been exceeded.", "scribunto-common-backtrace": "Backtrace:", diff --git a/i18n/qqq.json b/i18n/qqq.json index b5ddce35..218181b6 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -33,9 +33,9 @@ "scribunto-console-cleared-session-lost": "Message displayed in the console when the session has expired.", "scribunto-common-error-category": "Tracking category for pages with errors from #invoke", "scribunto-common-error-category-desc": "Description on [[Special:TrackingCategories]] for the {{msg-mw|scribunto-common-error-category}} tracking category.", - "scribunto-common-nosuchmodule": "Error message displayed when referencing a non-existing module.", + "scribunto-common-nosuchmodule": "Error message displayed when referencing a non-existing module. Parameters:\n* $1 - (Unused)\n* $2 - the title of the module", "scribunto-common-nofunction": "Error message displayed when not specifying a function to call.", - "scribunto-common-nosuchfunction": "Error message displayed when referencing a non-existing function.", + "scribunto-common-nosuchfunction": "Error message displayed when referencing a non-existing function. Parameters:\n* $1 - (Unused)\n* $2 - the name of the function", "scribunto-common-timeout": "Error message displayed when script execution has passed a threshold.", "scribunto-common-oom": "Error message displayed when the script requires more memory than the threshold.", "scribunto-common-backtrace": "A backtrace is a list of the function calls that are currently active in a thread. This message is followed by a backtrace.", diff --git a/tests/engines/LuaCommon/luaParserTests.txt b/tests/engines/LuaCommon/luaParserTests.txt index f16cd752..68e1bafa 100644 --- a/tests/engines/LuaCommon/luaParserTests.txt +++ b/tests/engines/LuaCommon/luaParserTests.txt @@ -185,7 +185,7 @@ Scribunto: no such module !! input {{#invoke:foo|bar}} !! result -

Script error +

Script error

!! end @@ -194,7 +194,7 @@ Scribunto: no such function !! input {{#invoke:test|blah}} !! result -

Script error +

Script error

!! end