mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 02:10:48 +00:00
Added Debugger shows (logs) unhandled exceptions
This commit is contained in:
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Label that flex compiler is used (when it's enabled in settings)
|
||||
- [#2119] Option to export assets with names like their assigned classes via SymbolClass, without character id
|
||||
- [#2119] Bulk imported assets can also match filenames based on assigned classname, not just character id prefix
|
||||
- Debugger shows (logs) unhandled exceptions
|
||||
|
||||
### Fixed
|
||||
- [#2021], [#2000] Caret position in editors when using tabs and / or unicode
|
||||
|
||||
@@ -139,6 +139,21 @@ public class DebugPanel extends JPanel {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void logAdd(String message) {
|
||||
boolean wasEmpty = logLength == 0;
|
||||
String add = message + "\r\n";
|
||||
logLength += add.length();
|
||||
traceLogTextarea.append(add);
|
||||
try {
|
||||
traceLogTextarea.setCaretPosition(logLength);
|
||||
} catch (IllegalArgumentException iex) {
|
||||
//ignore
|
||||
}
|
||||
if (wasEmpty) {
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public DebugPanel() {
|
||||
super(new BorderLayout());
|
||||
@@ -273,21 +288,19 @@ public class DebugPanel extends JPanel {
|
||||
@Override
|
||||
public void trace(String... val) {
|
||||
for (String s : val) {
|
||||
String add = "trace: " + s + "\r\n";
|
||||
boolean wasEmpty = logLength == 0;
|
||||
logLength += add.length();
|
||||
traceLogTextarea.append(add);
|
||||
try {
|
||||
traceLogTextarea.setCaretPosition(logLength);
|
||||
} catch (IllegalArgumentException iex) {
|
||||
//ignore
|
||||
}
|
||||
if (wasEmpty) {
|
||||
refresh();
|
||||
}
|
||||
logAdd("trace: " + s);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Main.getDebugHandler().addErrorListener(new DebuggerHandler.ErrorListener() {
|
||||
@Override
|
||||
public void errorException(String message, Variable thrownVar) {
|
||||
logAdd("unhandled exception: " + message);
|
||||
selectedTab = tabTypes.get(tabTypes.size() - 1);
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
Main.getDebugHandler().addConnectionListener(new DebuggerHandler.ConnectionListener() {
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.jpexs.debugger.flash.messages.in.InBreakReason;
|
||||
import com.jpexs.debugger.flash.messages.in.InCallFunction;
|
||||
import com.jpexs.debugger.flash.messages.in.InConstantPool;
|
||||
import com.jpexs.debugger.flash.messages.in.InContinue;
|
||||
import com.jpexs.debugger.flash.messages.in.InErrorException;
|
||||
import com.jpexs.debugger.flash.messages.in.InFrame;
|
||||
import com.jpexs.debugger.flash.messages.in.InGetSwd;
|
||||
import com.jpexs.debugger.flash.messages.in.InGetSwf;
|
||||
@@ -359,6 +360,8 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
|
||||
private final List<TraceListener> traceListeners = new ArrayList<>();
|
||||
|
||||
private final List<ErrorListener> errorListeners = new ArrayList<>();
|
||||
|
||||
private final List<FrameChangeListener> frameChangeListeners = new ArrayList<>();
|
||||
|
||||
private final List<ConnectionListener> clisteners = new ArrayList<>();
|
||||
@@ -413,6 +416,10 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
public void trace(String... val);
|
||||
}
|
||||
|
||||
public static interface ErrorListener {
|
||||
public void errorException(String message, Variable thrownVar);
|
||||
}
|
||||
|
||||
public static interface FrameChangeListener {
|
||||
|
||||
public void frameChanged();
|
||||
@@ -444,6 +451,14 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
public void removeTraceListener(TraceListener l) {
|
||||
traceListeners.remove(l);
|
||||
}
|
||||
|
||||
public void addErrorListener(ErrorListener l) {
|
||||
errorListeners.add(l);
|
||||
}
|
||||
|
||||
public void removeErrorListener(ErrorListener l) {
|
||||
errorListeners.remove(l);
|
||||
}
|
||||
|
||||
public void removeBreakListener(BreakListener l) {
|
||||
breakListeners.remove(l);
|
||||
@@ -610,6 +625,17 @@ public class DebuggerHandler implements DebugConnectionListener {
|
||||
boolean isAS3 = (Main.getMainFrame().getPanel().getCurrentSwf().isAS3());
|
||||
try {
|
||||
|
||||
|
||||
con.addMessageListener(new DebugMessageListener<InErrorException>() {
|
||||
@Override
|
||||
public void message(InErrorException t) {
|
||||
for (ErrorListener l : errorListeners) {
|
||||
l.errorException(t.exceptionMessage, t.thrownVar);
|
||||
}
|
||||
con.dropMessage(t);
|
||||
}
|
||||
});
|
||||
|
||||
con.addMessageListener(new DebugMessageListener<InNumScript>() {
|
||||
@Override
|
||||
public void message(InNumScript t) {
|
||||
|
||||
Reference in New Issue
Block a user