From fd5fddc2ccf5bafe810c3a9363a4f347742a609a Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Fri, 15 Mar 2013 17:04:58 +0000 Subject: [PATCH] Returning an error was awkward. Panic when people do things wrong instead. --- client/connection.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/connection.go b/client/connection.go index 578f15b..f093125 100644 --- a/client/connection.go +++ b/client/connection.go @@ -96,14 +96,14 @@ func NewConfig(nick string, args ...string) *Config { // 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 func SimpleClient(nick string, args ...string) *Conn { - conn, _ := Client(NewConfig(nick, args...)) + conn := Client(NewConfig(nick, args...)) return conn } -func Client(cfg *Config) (*Conn, error) { +func Client(cfg *Config) *Conn { logging.InitFromFlags() - if 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.") + if cfg == nil || cfg.Me == nil || cfg.Me.Nick == "" || cfg.Me.Ident == "" { + logging.Fatal("irc.Client(): Both cfg.Nick and cfg.Ident must be non-empty.") } conn := &Conn{ cfg: cfg, @@ -118,7 +118,7 @@ func Client(cfg *Config) (*Conn, error) { } conn.addIntHandlers() conn.initialise() - return conn, nil + return conn } func (conn *Conn) Connected() bool {