forked from kkdai/youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
46 lines (36 loc) · 1.16 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
package youtube
import (
"errors"
"fmt"
)
var (
ErrCipherNotFound = errors.New("cipher not found")
ErrInvalidCharactersInVideoID = errors.New("invalid characters in video id")
ErrVideoIDMinLength = errors.New("the video id must be at least 10 characters long")
ErrReadOnClosedResBody = errors.New("http: read on closed response body")
)
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)
}