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)
|
dj.SendPrivateMessage(user, NO_ARGUMENT_MSG)
|
||||||
return errors.New("NO_ARGUMENT")
|
return errors.New("NO_ARGUMENT")
|
||||||
} else {
|
} 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 {
|
if urlService == nil {
|
||||||
|
Verbose("Invalid_URL")
|
||||||
return errors.New("INVALID_URL")
|
return errors.New("INVALID_URL")
|
||||||
} else {
|
} else {
|
||||||
oldLength := dj.queue.Len()
|
oldLength := dj.queue.Len()
|
||||||
|
|
|
@ -58,7 +58,12 @@ func (sc SoundCloud) NewRequest(user *gumble.User, url string) (string, error) {
|
||||||
for _, t := range tracks {
|
for _, t := range tracks {
|
||||||
sc.NewSong(user.Name, jsonq.NewQuery(t), playlist)
|
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 {
|
} else {
|
||||||
return "", errors.New("NO_PLAYLIST_PERMISSION")
|
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]
|
startOffset = matches[0][2]
|
||||||
}
|
}
|
||||||
song, err := yt.NewSong(user.Name, shortURL, startOffset, nil)
|
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 {
|
} else {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
5
test.go
5
test.go
|
@ -3,10 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/layeh/gumble/gumble"
|
"github.com/layeh/gumble/gumble"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(password, ip, port string) {
|
func Test(password, ip, port string) {
|
||||||
|
testYoutubeSong(password, ip, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createClient(uname, password, ip, port string) *gumble.Client {
|
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 {
|
} else if dj.queue.CurrentSong().Title() != title {
|
||||||
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, dj.queue.CurrentSong().Title())
|
fmt.Printf("For: %s; Expected: %s; Got: %s", url, title, dj.queue.CurrentSong().Title())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sleep(time.Second * 5)
|
||||||
skip(dummyUser, false, false)
|
skip(dummyUser, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue