package main import ( "errors" ) // TODO: multiple services... func TryLogin(task *Task, conn *Connection) (res bool, err error) { defer func() { if r := recover(); r != nil { log("srv", 1, "fatal error (panic) in service handler: %v", r) res = false switch x := r.(type) { case string: err = errors.New(x) case error: err = x default: err = errors.New("unknown error") } } }() res, err = NewLegacyWinbox(task, conn).TryLogin() return res, err }