Added more error messages
This commit is contained in:
parent
af9b4d8405
commit
46820b68ea
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
5
test.go
5
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)
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue