mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-23 15:56:55 +00:00
LuaSandbox backtraces
* Updates for the LuaSandbox backtrace feature introduced in r115020. * Fixed a notice in the case where the backtrace is not available * Implemented error message parsing for file/line as in LuaStandalone Change-Id: Ie1e053784e174aa53ebf5a1fa782d3cf6243c3f0
This commit is contained in:
parent
41b93dd7e1
commit
fa6dd44957
|
@ -238,6 +238,9 @@ class Scribunto_LuaError extends ScribuntoException {
|
|||
}
|
||||
|
||||
function getScriptTraceHtml( $options = array() ) {
|
||||
if ( !isset( $this->params['trace'] ) ) {
|
||||
return false;
|
||||
}
|
||||
global $wgUser;
|
||||
$skin = $wgUser->getSkin();
|
||||
if ( isset( $options['msgOptions'] ) ){
|
||||
|
|
|
@ -30,11 +30,25 @@ class Scribunto_LuaSandboxInterpreter extends Scribunto_LuaInterpreter {
|
|||
$this->sandbox->setCPULimit( $options['cpuLimit'] );
|
||||
}
|
||||
|
||||
protected function convertSandboxError( $e ) {
|
||||
$opts = array();
|
||||
if ( isset( $e->luaTrace ) ) {
|
||||
$opts['trace'] = $e->luaTrace;
|
||||
}
|
||||
$message = $e->getMessage();
|
||||
if ( preg_match( '/^(.*?):(\d+): (.*)$/', $message, $m ) ) {
|
||||
$opts['module'] = $m[1];
|
||||
$opts['line'] = $m[2];
|
||||
$message = $m[3];
|
||||
}
|
||||
return $this->engine->newLuaError( $message, $opts );
|
||||
}
|
||||
|
||||
public function loadString( $text, $chunkName ) {
|
||||
try {
|
||||
return $this->sandbox->loadString( $text, $chunkName );
|
||||
} catch ( LuaSandboxError $e ) {
|
||||
throw $this->engine->newLuaError( $e->getMessage() );
|
||||
throw $this->convertSandboxError( $e );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +74,7 @@ class Scribunto_LuaSandboxInterpreter extends Scribunto_LuaInterpreter {
|
|||
} catch ( LuaSandboxTimeoutError $e ) {
|
||||
throw $this->engine->newException( 'scribunto-common-timeout' );
|
||||
} catch ( LuaSandboxError $e ) {
|
||||
throw $this->engine->newLuaError( $e->getMessage() );
|
||||
throw $this->convertSandboxError( $e );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue