Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Panics: leaky abstractions #133

Closed
JensRantil opened this issue Nov 24, 2013 · 3 comments
Closed

Panics: leaky abstractions #133

JensRantil opened this issue Nov 24, 2013 · 3 comments

Comments

@JensRantil
Copy link
Contributor

I've just spent part of my evening reading the source code. I notice in server.go that error is returned in some cases, while panic(...) is called in other error cases. Here's an example.

A Go blog article states

The convention in the Go libraries is that even when a package uses panic internally, its external API still presents explicit error return values.

My question is, is there a specific reason as to why the raft library uses panic(...) as opposed to errors? Does it distinguish between the two somehow?

@xiang90
Copy link
Contributor

xiang90 commented Nov 24, 2013

@JensRantil I think we use panic as assert. Feel free to send pr to clean up.

@benbjohnson
Copy link
Contributor

@JensRantil Some of the panics are for unrecoverable errors. We should use errors instead most of the time. The ones in command.go are there because they shouldn't fail but if they do then it'll typically happen at initialization. As Xiang said, feel free to send a PR. Otherwise we can try to tackle it in the near future.

@JensRantil
Copy link
Contributor Author

Ok! Thanks for quick response!

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

No branches or pull requests

3 participants