-
Notifications
You must be signed in to change notification settings - Fork 435
/
errors.go
47 lines (37 loc) · 1.43 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package youtube
import (
"fmt"
)
const (
ErrCipherNotFound = constError("cipher not found")
ErrSignatureTimestampNotFound = constError("signature timestamp not found")
ErrInvalidCharactersInVideoID = constError("invalid characters in video id")
ErrVideoIDMinLength = constError("the video id must be at least 10 characters long")
ErrReadOnClosedResBody = constError("http: read on closed response body")
ErrNotPlayableInEmbed = constError("embedding of this video has been disabled")
ErrLoginRequired = constError("login required to confirm your age")
ErrVideoPrivate = constError("user restricted access to this video")
ErrInvalidPlaylist = constError("no playlist detected or invalid playlist ID")
)
type constError string
func (e constError) Error() string {
return string(e)
}
type ErrPlayabiltyStatus struct {
Status string
Reason string
}
func (err ErrPlayabiltyStatus) Error() string {
return fmt.Sprintf("cannot playback and download, status: %s, reason: %s", err.Status, err.Reason)
}
// ErrUnexpectedStatusCode is returned on unexpected HTTP status codes
type ErrUnexpectedStatusCode int
func (err ErrUnexpectedStatusCode) Error() string {
return fmt.Sprintf("unexpected status code: %d", err)
}
type ErrPlaylistStatus struct {
Reason string
}
func (err ErrPlaylistStatus) Error() string {
return fmt.Sprintf("could not load playlist: %s", err.Reason)
}