Skip to content

Commit

Permalink
Handle bad launch files correctly (#262)
Browse files Browse the repository at this point in the history
* Handle the case where a launch file is invalid

* Handle the roslaunch no output case correctly
  • Loading branch information
ooeygui authored Jul 14, 2020
1 parent fe9d54b commit 15c4b0c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/debugger/configuration/resolvers/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider {
};

let result = await promisifiedExec(`roslaunch --dump-params ${config.target}`, rosExecOptions);
if (result.stderr) {
throw (new Error(`Error from roslaunch:\r\n ${result.stderr}`));
} else if (result.stdout.length == 0) {
throw (new Error(`roslaunch unexpectedly produced no output, please test by running \"roslaunch --dump-params ${config.target}\" in a ros terminal.`));
}


const parameters = Object.keys(yaml.load(result.stdout));
if (parameters && parameters.length) {
// only call into rosparam when necessary
Expand All @@ -51,6 +58,11 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider {
}

result = await promisifiedExec(`roslaunch --nodes ${config.target}`, rosExecOptions);
if (result.stderr) {
throw (new Error(`Error from roslaunch:\r\n ${result.stderr}`));
} else if (result.stdout.length == 0) {
throw (new Error(`roslaunch unexpectedly produced no output, please test by running \"roslaunch --dump-params ${config.target}\" in a ros terminal.`));
}
const nodes = result.stdout.trim().split(os.EOL);
await Promise.all(nodes.map((node: string) => {
return promisifiedExec(`roslaunch --args ${node} ${config.target}`, rosExecOptions);
Expand Down

0 comments on commit 15c4b0c

Please sign in to comment.