Ask Your Question
0

How to get error information using roslibjs

asked 2015-05-11 20:12:45 -0600

Joseph Landau gravatar image

Using roslibjs and rosbridge--I'd like to get more information when there is an error, particularly when connecting. My code is:

ros = new ROSLIB.Ros({
url: robotUrl
});

ros.on('error', function(error) { console.log ('Error connecting to websocket server: ' , error); });

When an error occurs, I see in the debugger that the variable "error" contains a very involved structure, and I guess the actual error message is in there somewhere, but where?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-05-12 09:33:49 -0600

rtoris288 gravatar image

updated 2015-05-12 09:34:12 -0600

The error variable is should always be a string. You can concatenate it in the console.log statement and it should work.

edit flag offensive delete link more

Comments

When I concatenate the error variable (here's the code): "console.log ('Error connecting to websocket server: ' + error);", the result is: "Error connecting to websocket server: [object Event]" Looks like the argument called error is an Event rather than a string?

Joseph Landau gravatar imageJoseph Landau ( 2015-05-12 12:36:31 -0600 )edit

Strange, what if you just log the error variable by itself? console.log(error);, this is based off a working example: https://github.com/RobotWebTools/rosl...

rtoris288 gravatar imagertoris288 ( 2015-05-12 13:17:34 -0600 )edit

In that case, I get: "Event {path: Array[0], cancelBubble: false, returnValue: true, srcElement: WebSocket, defaultPrevented: false…}" This is clickable and expands to show lots of properties. Incidentally, the debugger shows that roslib.js (line 651?) has the message. Or, at least, a message.

Joseph Landau gravatar imageJoseph Landau ( 2015-05-12 19:10:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-11 20:12:45 -0600

Seen: 109 times

Last updated: May 12 '15