Search in sources :

Example 1 with NodeJsDebuggerException

use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException in project che by eclipse.

the class NodeJsDebugProcess method initializeNodeJsDebugProcess.

private Process initializeNodeJsDebugProcess(String[] options) throws NodeJsDebuggerException {
    List<String> commands = new ArrayList<>(1 + options.length);
    commands.add(NODEJS_COMMAND);
    commands.addAll(Arrays.asList(options));
    ProcessBuilder processBuilder = new ProcessBuilder(commands);
    try {
        return processBuilder.start();
    } catch (IOException e) {
        throw new NodeJsDebuggerException("NodeJs process initialization failed.", e);
    }
}
Also used : NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) IOException(java.io.IOException)

Example 2 with NodeJsDebuggerException

use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException 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);
    }
}
Also used : DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)

Example 3 with NodeJsDebuggerException

use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException 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);
    }
}
Also used : NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException) Location(org.eclipse.che.api.debug.shared.model.Location)

Example 4 with NodeJsDebuggerException

use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException in project che by eclipse.

the class NodeJsDebugProcess method send.

/**
     * Synchronizes sending commands.
     */
public synchronized void send(String command) throws NodeJsDebuggerException {
    LOG.debug("Execute: {}", command);
    if (!process.isAlive()) {
        throw new NodeJsDebuggerTerminatedException("NodeJs process has been terminated.");
    }
    try {
        processWriter.write(command);
        processWriter.newLine();
        processWriter.flush();
    } catch (IOException e) {
        throw new NodeJsDebuggerException(e.getMessage(), e);
    }
}
Also used : NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) IOException(java.io.IOException) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)

Example 5 with NodeJsDebuggerException

use of org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException 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);
    }
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) NodeJsDebuggerException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException) BreakpointActivatedEventImpl(org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl) NodeJsDebuggerTerminatedException(org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException) Location(org.eclipse.che.api.debug.shared.model.Location)

Aggregations

NodeJsDebuggerException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerException)5 NodeJsDebuggerTerminatedException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerTerminatedException)4 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)3 IOException (java.io.IOException)2 Location (org.eclipse.che.api.debug.shared.model.Location)2 BreakpointActivatedEventImpl (org.eclipse.che.api.debug.shared.model.impl.event.BreakpointActivatedEventImpl)2 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)1