From 46820b68eae647c825e4dba63e8b6ba56fd779ca Mon Sep 17 00:00:00 2001 From: MichaelOultram Date: Mon, 10 Aug 2015 19:29:58 +0100 Subject: [PATCH] Added more error messages --- commands.go | 6 +++++- service.go | 1 + service_soundcloud.go | 7 ++++++- service_youtube.go | 7 ++++++- test.go | 5 ++++- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/commands.go b/commands.go index 5dde0c4..22121e2 100644 --- a/commands.go +++ b/commands.go @@ -171,7 +171,11 @@ func add(user *gumble.User, url string) error { dj.SendPrivateMessage(user, NO_ARGUMENT_MSG) return errors.New("NO_ARGUMENT") } else { - return findServiceAndAdd(user, url) + err := findServiceAndAdd(user, url) + if err != nil { + dj.SendPrivateMessage(user, err.Error()) + } + return err } } diff --git a/service.go b/service.go index a83ddba..15a5947 100644 --- a/service.go +++ b/service.go @@ -65,6 +65,7 @@ func findServiceAndAdd(user *gumble.User, url string) error { } if urlService == nil { + Verbose("Invalid_URL") return errors.New("INVALID_URL") } else { oldLength := dj.queue.Len() diff --git a/service_soundcloud.go b/service_soundcloud.go index 01def80..aa43e2f 100644 --- a/service_soundcloud.go +++ b/service_soundcloud.go @@ -58,7 +58,12 @@ func (sc SoundCloud) NewRequest(user *gumble.User, url string) (string, error) { for _, t := range tracks { sc.NewSong(user.Name, jsonq.NewQuery(t), playlist) } - return playlist.Title(), err + if err == nil { + return playlist.Title(), nil + } else { + Verbose("soundcloud.NewRequest: " + err.Error()) + return nil, err + } } else { return "", errors.New("NO_PLAYLIST_PERMISSION") } diff --git a/service_youtube.go b/service_youtube.go index a8c2b44..ff1b9ec 100644 --- a/service_youtube.go +++ b/service_youtube.go @@ -73,7 +73,12 @@ func (yt YouTube) NewRequest(user *gumble.User, url string) (string, error) { startOffset = matches[0][2] } song, err := yt.NewSong(user.Name, shortURL, startOffset, nil) - return song.Title(), err + if err == nil { + return song.Title(), nil + } else { + Verbose("youtube.NewRequest: " + err.Error()) + return nil, err + } } } else { return "", err diff --git a/test.go b/test.go index ba8067c..e5ae017 100644 --- a/test.go +++ b/test.go @@ -3,10 +3,11 @@ package main import ( "fmt" "github.com/layeh/gumble/gumble" + "time" ) func Test(password, ip, port string) { - + testYoutubeSong(password, ip, port) } func createClient(uname, password, ip, port string) *gumble.Client { @@ -40,6 +41,8 @@ func testYoutubeSong(password, ip, port string) { } else if dj.queue.CurrentSong().Title() != title { fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, dj.queue.CurrentSong().Title()) } + + sleep(time.Second * 5) skip(dummyUser, false, false) }