Added more error messages

This commit is contained in:
MichaelOultram 2015-08-10 19:29:58 +01:00
parent af9b4d8405
commit 46820b68ea
5 changed files with 22 additions and 4 deletions

View file

@ -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
}
}

View file

@ -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()

View file

@ -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")
}

View file

@ -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

View file

@ -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)
}