Returning an error was awkward. Panic when people do things wrong instead.

This commit is contained in:
Alex Bramley 2013-03-15 17:04:58 +00:00
parent e6cf0933b5
commit fd5fddc2cc
1 changed files with 5 additions and 5 deletions

View File

@ -96,14 +96,14 @@ func NewConfig(nick string, args ...string) *Config {
// Creates a new IRC connection object, but doesn't connect to anything so // Creates a new IRC connection object, but doesn't connect to anything so
// that you can add event handlers to it. See AddHandler() for details // that you can add event handlers to it. See AddHandler() for details
func SimpleClient(nick string, args ...string) *Conn { func SimpleClient(nick string, args ...string) *Conn {
conn, _ := Client(NewConfig(nick, args...)) conn := Client(NewConfig(nick, args...))
return conn return conn
} }
func Client(cfg *Config) (*Conn, error) { func Client(cfg *Config) *Conn {
logging.InitFromFlags() logging.InitFromFlags()
if cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" { if cfg == nil || cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" {
return nil, fmt.Errorf("irc.Client(): Both cfg.Nick and cfg.Ident must be non-empty.") logging.Fatal("irc.Client(): Both cfg.Nick and cfg.Ident must be non-empty.")
} }
conn := &Conn{ conn := &Conn{
cfg: cfg, cfg: cfg,
@ -118,7 +118,7 @@ func Client(cfg *Config) (*Conn, error) {
} }
conn.addIntHandlers() conn.addIntHandlers()
conn.initialise() conn.initialise()
return conn, nil return conn
} }
func (conn *Conn) Connected() bool { func (conn *Conn) Connected() bool {