Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't do os.Exit() #28

Open
gelin opened this issue Jul 22, 2019 · 0 comments
Open

Don't do os.Exit() #28

gelin opened this issue Jul 22, 2019 · 0 comments

Comments

@gelin
Copy link

gelin commented Jul 22, 2019

Current implementation calls logger.Fatalf() (and os.Exit() inside) when it's not possible to create objects.

For example:

func (node *defaultNode) NewPublisherWithCallbacks(topic string, msgType MessageType, connectCallback, disconnectCallback func(SingleSubscriberPublisher)) Publisher {
	//...
		_, err := callRosApi(node.masterUri, "registerPublisher",
			node.qualifiedName,
			name, msgType.Name(),
			node.xmlrpcUri)
		if err != nil {
			logger.Fatalf("Failed to call registerPublisher(): %s", err)
		}
	//...
}

The better is to return (Publisher, error) in this case and involve typical Go error handling mechanics than unconditionally die.

I'm building a service where ROS node can be started later, some functionality of it doesn't depend on ROS. But I cannot start when ROS master is not available because of os.Exit() in the rosgo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant