use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.
the class JdiStackFrameImpl method getFields.
@Override
public JdiField[] getFields() throws DebuggerException {
if (fields == null) {
try {
ObjectReference object = stackFrame.thisObject();
if (object == null) {
ReferenceType type = stackFrame.location().declaringType();
List<Field> fs = stackFrame.location().declaringType().allFields();
fields = new JdiField[fs.size()];
int i = 0;
for (Field f : fs) {
fields[i++] = new JdiFieldImpl(f, type);
}
} else {
List<Field> fs = object.referenceType().allFields();
fields = new JdiField[fs.size()];
int i = 0;
for (Field f : fs) {
fields[i++] = new JdiFieldImpl(f, object);
}
}
Arrays.sort(fields);
} catch (InvalidStackFrameException e) {
throw new DebuggerException(e.getMessage(), e);
}
}
return fields;
}
use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.
the class NodeJsDebugger method setValue.
@Override
public void setValue(Variable variable) throws DebuggerException {
try {
List<String> path = variable.getVariablePath().getPath();
if (path.isEmpty()) {
throw new DebuggerException("Variable path is empty");
}
library.setVar(path.get(0), variable.getValue());
} catch (NodeJsDebuggerTerminatedException e) {
disconnect();
throw e;
} catch (NodeJsDebuggerException e) {
throw new DebuggerException("Can't set value for " + variable.getName() + ". " + e.getMessage(), e);
}
}
use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.
the class NodeJsDebugger method addBreakpoint.
@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
try {
Location location = breakpoint.getLocation();
library.setBreakpoint(location.getTarget(), location.getLineNumber());
debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
} catch (NodeJsDebuggerTerminatedException e) {
disconnect();
throw e;
} catch (NodeJsDebuggerException e) {
throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e);
}
}
use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.
the class NodeJsDebugger method start.
@Override
public void start(StartAction action) throws DebuggerException {
try {
for (Breakpoint breakpoint : action.getBreakpoints()) {
Location location = breakpoint.getLocation();
library.setBreakpoint(location.getTarget(), location.getLineNumber());
debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
}
library.backtrace();
} catch (NodeJsDebuggerTerminatedException e) {
disconnect();
throw e;
} catch (NodeJsDebuggerException e) {
throw new DebuggerException("Start error. " + e.getMessage(), e);
}
}
use of org.eclipse.che.api.debugger.server.exceptions.DebuggerException in project che by eclipse.
the class NodeJsDebuggerFactory method create.
@Override
public Debugger create(Map<String, String> properties, Debugger.DebuggerCallback debuggerCallback) throws DebuggerException {
Map<String, String> normalizedProps = properties.entrySet().stream().collect(toMap(e -> e.getKey().toLowerCase(), Map.Entry::getValue));
Integer pid = null;
URI uri = null;
String pidStr = normalizedProps.get("pid");
if (!isNullOrEmpty(pidStr)) {
try {
pid = Integer.valueOf(pidStr);
} catch (NumberFormatException e) {
throw new DebuggerException(String.format("Illegal 'pid' format %s. Debugger can't be started.", pidStr));
}
}
String uriStr = normalizedProps.get("uri");
if (!isNullOrEmpty(uriStr)) {
try {
uri = URI.create(uriStr);
} catch (IllegalArgumentException e) {
throw new DebuggerException(String.format("Illegal 'uri' format %s. Debugger can't be started.", uriStr));
}
}
String script = normalizedProps.get("script");
if (!isNullOrEmpty(script) && !Files.exists(Paths.get(script))) {
throw new DebuggerException(String.format("Script '%s' to debug not found. Debugger can't be started.", script));
}
if (isNullOrEmpty(pidStr) && isNullOrEmpty(uriStr) && isNullOrEmpty(script)) {
throw new DebuggerException("Unrecognized debug connection options. Allowed only: pid, uri or script.");
}
return NodeJsDebugger.newInstance(pid, uri, script, debuggerCallback);
}
Aggregations