-
Notifications
You must be signed in to change notification settings - Fork 44
/
errors.go
106 lines (98 loc) · 3.25 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package mega
import (
"errors"
"fmt"
)
var (
// General errors
EINTERNAL = errors.New("Internal error occured")
EARGS = errors.New("Invalid arguments")
EAGAIN = errors.New("Try again")
ERATELIMIT = errors.New("Rate limit reached")
EBADRESP = errors.New("Bad response from server")
// Upload errors
EFAILED = errors.New("The upload failed. Please restart it from scratch")
ETOOMANY = errors.New("Too many concurrent IP addresses are accessing this upload target URL")
ERANGE = errors.New("The upload file packet is out of range or not starting and ending on a chunk boundary")
EEXPIRED = errors.New("The upload target URL you are trying to access has expired. Please request a fresh one")
// Filesystem/Account errors
ENOENT = errors.New("Object (typically, node or user) not found")
ECIRCULAR = errors.New("Circular linkage attempted")
EACCESS = errors.New("Access violation")
EEXIST = errors.New("Trying to create an object that already exists")
EINCOMPLETE = errors.New("Trying to access an incomplete resource")
EKEY = errors.New("A decryption operation failed")
ESID = errors.New("Invalid or expired user session, please relogin")
EBLOCKED = errors.New("User blocked")
EOVERQUOTA = errors.New("Request over quota")
ETEMPUNAVAIL = errors.New("Resource temporarily not available, please try again later")
EMACMISMATCH = errors.New("MAC verification failed")
EBADATTR = errors.New("Bad node attribute")
ETOOMANYCONNECTIONS = errors.New("Too many connections on this resource.")
EWRITE = errors.New("File could not be written to (or failed post-write integrity check).")
EREAD = errors.New("File could not be read from (or changed unexpectedly during reading).")
EAPPKEY = errors.New("Invalid or missing application key.")
ESSL = errors.New("SSL verification failed")
EGOINGOVERQUOTA = errors.New("Not enough quota")
EMFAREQUIRED = errors.New("Multi-factor authentication required")
// Config errors
EWORKER_LIMIT_EXCEEDED = errors.New("Maximum worker limit exceeded")
)
type ErrorMsg int
func parseError(errno ErrorMsg) error {
switch {
case errno == 0:
return nil
case errno == -1:
return EINTERNAL
case errno == -2:
return EARGS
case errno == -3:
return EAGAIN
case errno == -4:
return ERATELIMIT
case errno == -5:
return EFAILED
case errno == -6:
return ETOOMANY
case errno == -7:
return ERANGE
case errno == -8:
return EEXPIRED
case errno == -9:
return ENOENT
case errno == -10:
return ECIRCULAR
case errno == -11:
return EACCESS
case errno == -12:
return EEXIST
case errno == -13:
return EINCOMPLETE
case errno == -14:
return EKEY
case errno == -15:
return ESID
case errno == -16:
return EBLOCKED
case errno == -17:
return EOVERQUOTA
case errno == -18:
return ETEMPUNAVAIL
case errno == -19:
return ETOOMANYCONNECTIONS
case errno == -20:
return EWRITE
case errno == -21:
return EREAD
case errno == -22:
return EAPPKEY
case errno == -23:
return ESSL
case errno == -24:
return EGOINGOVERQUOTA
case errno == -26:
return EMFAREQUIRED
}
return fmt.Errorf("Unknown mega error %d", errno)
}