Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Improved scripting error messages.
Dieser Commit ist enthalten in:
Ursprung
e94e1e29ce
Commit
768ff9387c
@ -2203,13 +2203,15 @@ public class WorldEditController {
|
|||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
player.printError("Failed to execute:");;
|
player.printError("Failed to execute:");;
|
||||||
player.printRaw(e.getMessage());
|
player.printRaw(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
player.printError("Failed to execute (exception):");
|
player.printError("Failed to execute (see console):");
|
||||||
player.printRaw(e.getClass().getCanonicalName());
|
player.printRaw(e.getClass().getCanonicalName());
|
||||||
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
for (EditSession editSession : scriptContext.getEditSessions()) {
|
for (EditSession editSession : scriptContext.getEditSessions()) {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.scripting;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
import org.mozilla.javascript.*;
|
import org.mozilla.javascript.*;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
||||||
public class RhinoCraftScriptEngine implements CraftScriptEngine {
|
public class RhinoCraftScriptEngine implements CraftScriptEngine {
|
||||||
private int timeLimit;
|
private int timeLimit;
|
||||||
@ -38,7 +39,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object evaluate(String script, String filename, Map<String, Object> args)
|
public Object evaluate(String script, String filename, Map<String, Object> args)
|
||||||
throws ScriptException {
|
throws ScriptException, Throwable {
|
||||||
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
|
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
|
||||||
Context cx = factory.enterContext();
|
Context cx = factory.enterContext();
|
||||||
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
ScriptableObject scriptable = new ImporterTopLevel(cx);
|
||||||
@ -53,6 +54,13 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
|
|||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
throw new ScriptException(e.getMessage());
|
throw new ScriptException(e.getMessage());
|
||||||
} catch (RhinoException e) {
|
} catch (RhinoException e) {
|
||||||
|
if (e instanceof WrappedException) {
|
||||||
|
Throwable cause = ((WrappedException)e).getCause();
|
||||||
|
if (cause instanceof WorldEditException) {
|
||||||
|
throw ((WrappedException)e).getCause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String msg;
|
String msg;
|
||||||
int line = (line = e.lineNumber()) == 0 ? -1 : line;
|
int line = (line = e.lineNumber()) == 0 ? -1 : line;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.scripting;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
import com.sk89q.worldedit.WorldEditController;
|
import com.sk89q.worldedit.WorldEditController;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import sun.org.mozilla.javascript.internal.*;
|
import sun.org.mozilla.javascript.internal.*;
|
||||||
|
|
||||||
public class SunRhinoCraftScriptEngine implements CraftScriptEngine {
|
public class SunRhinoCraftScriptEngine implements CraftScriptEngine {
|
||||||
@ -63,7 +64,10 @@ public class SunRhinoCraftScriptEngine implements CraftScriptEngine {
|
|||||||
throw new ScriptException(e.getMessage());
|
throw new ScriptException(e.getMessage());
|
||||||
} catch (RhinoException e) {
|
} catch (RhinoException e) {
|
||||||
if (e instanceof WrappedException) {
|
if (e instanceof WrappedException) {
|
||||||
throw ((WrappedException)e).getCause();
|
Throwable cause = ((WrappedException)e).getCause();
|
||||||
|
if (cause instanceof WorldEditException) {
|
||||||
|
throw ((WrappedException)e).getCause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String msg;
|
String msg;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren