forked from kkdai/youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
53 lines (41 loc) · 1.41 KB
/
errors.go
File metadata and controls
53 lines (41 loc) · 1.41 KB
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
48
49
50
51
52
53
package youtube
import (
"fmt"
)
const (
ErrCipherNotFound = constError("cipher 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")
ErrInvalidPlaylist = constError("no playlist detected or invalid playlist ID")
)
type constError string
func (e constError) Error() string {
return string(e)
}
type ErrResponseStatus struct {
Status string
Reason string
}
func (err ErrResponseStatus) Error() string {
if err.Status == "" {
return "no response status found in the server's answer"
}
if err.Reason == "" {
return fmt.Sprintf("response status: '%s', no reason given", err.Status)
}
return fmt.Sprintf("response status: '%s', reason: '%s'", err.Status, err.Reason)
}
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)
}