forked from gen2brain/malgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
124 lines (120 loc) · 5.05 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package malgo
import "fmt"
// Errors.
var (
errTag = "mini_al"
ErrError = fmt.Errorf("%s: generic error", errTag)
ErrInvalidArgs = fmt.Errorf("%s: invalid args", errTag)
ErrInvalidOperation = fmt.Errorf("%s: invalid operation", errTag)
ErrOutOfMemory = fmt.Errorf("%s: out of memory", errTag)
ErrFormatNotSupported = fmt.Errorf("%s: format not supported", errTag)
ErrNoBackend = fmt.Errorf("%s: no backend", errTag)
ErrNoDevice = fmt.Errorf("%s: no device", errTag)
ErrAPINotFound = fmt.Errorf("%s: api not found", errTag)
ErrDeviceBusy = fmt.Errorf("%s: device busy", errTag)
ErrDeviceNotInitialized = fmt.Errorf("%s: device busy", errTag)
ErrDeviceNotStarted = fmt.Errorf("%s: device not started", errTag)
ErrDeviceNotStopped = fmt.Errorf("%s: device not stopped", errTag)
ErrDeviceAlreadyStarted = fmt.Errorf("%s: device already started", errTag)
ErrDeviceAlreadyStarting = fmt.Errorf("%s: device already starting", errTag)
ErrDeviceAlreadyStopped = fmt.Errorf("%s: device already stopped", errTag)
ErrDeviceAlreadyStopping = fmt.Errorf("%s: device already stopping", errTag)
ErrFailedToMapDeviceBuffer = fmt.Errorf("%s: failed to map device buffer", errTag)
ErrFailedToUnmapDeviceBuffer = fmt.Errorf("%s: failed to unmap device buffer", errTag)
ErrFailedToInitBackend = fmt.Errorf("%s: failed to init backend", errTag)
ErrFailedToReadDataFromClient = fmt.Errorf("%s: failed to read data from client", errTag)
ErrFailedToReadDataFromDevice = fmt.Errorf("%s: failed to read data from device", errTag)
ErrFailedToSendDataToClient = fmt.Errorf("%s: failed to send data to client", errTag)
ErrFailedToSendDataToDevice = fmt.Errorf("%s: failed to send data to device", errTag)
ErrFailedToOpenBackendDevice = fmt.Errorf("%s: failed to open backend device", errTag)
ErrFailedToStartBackendDevice = fmt.Errorf("%s: failed to start backend device", errTag)
ErrFailedToStopBackendDevice = fmt.Errorf("%s: failed to stop backend device", errTag)
ErrFailedToConfigureBackendDevice = fmt.Errorf("%s: failed to configure backend device", errTag)
ErrFailedToCreateMutex = fmt.Errorf("%s: failed to create mutex", errTag)
ErrFailedToCreateEvent = fmt.Errorf("%s: failed to create event", errTag)
ErrFailedToCreateThread = fmt.Errorf("%s: failed to create thread", errTag)
ErrInvalidDeviceConfig = fmt.Errorf("%s: invalid device config", errTag)
ErrAccessDenied = fmt.Errorf("%s: access denied", errTag)
ErrTooLarge = fmt.Errorf("%s: too large", errTag)
ErrDeviceUnavailable = fmt.Errorf("%s: device unavailable", errTag)
ErrTimeout = fmt.Errorf("%s: timeout", errTag)
)
// errorFromResult returns error for result code.
func errorFromResult(r Result) error {
switch r {
case Success:
return nil
case Error:
return ErrError
case InvalidArgs:
return ErrInvalidArgs
case InvalidOperation:
return ErrInvalidOperation
case OutOfMemory:
return ErrOutOfMemory
case FormatNotSupported:
return ErrFormatNotSupported
case NoBackend:
return ErrNoBackend
case NoDevice:
return ErrNoDevice
case APINotFound:
return ErrAPINotFound
case DeviceBusy:
return ErrDeviceBusy
case DeviceNotInitialized:
return ErrDeviceNotInitialized
case DeviceNotStarted:
return ErrDeviceNotStarted
case DeviceNotStopped:
return ErrDeviceNotStopped
case DeviceAlreadyStarted:
return ErrDeviceAlreadyStarted
case DeviceAlreadyStarting:
return ErrDeviceAlreadyStarting
case DeviceAlreadyStopped:
return ErrDeviceAlreadyStopped
case DeviceAlreadyStopping:
return ErrDeviceAlreadyStopping
case FailedToMapDeviceBuffer:
return ErrFailedToMapDeviceBuffer
case FailedToUnmapDeviceBuffer:
return ErrFailedToUnmapDeviceBuffer
case FailedToInitBackend:
return ErrFailedToInitBackend
case FailedToReadDataFromClient:
return ErrFailedToReadDataFromClient
case FailedToReadDataFromDevice:
return ErrFailedToReadDataFromDevice
case FailedToSendDataToClient:
return ErrFailedToSendDataToClient
case FailedToSendDataToDevice:
return ErrFailedToSendDataToDevice
case FailedToOpenBackendDevice:
return ErrFailedToOpenBackendDevice
case FailedToStartBackendDevice:
return ErrFailedToStartBackendDevice
case FailedToStopBackendDevice:
return ErrFailedToStopBackendDevice
case FailedToConfigureBackendDevice:
return ErrFailedToConfigureBackendDevice
case FailedToCreateMutex:
return ErrFailedToCreateMutex
case FailedToCreateEvent:
return ErrFailedToCreateEvent
case FailedToCreateThread:
return ErrFailedToCreateThread
case InvalidDeviceConfig:
return ErrInvalidDeviceConfig
case AccessDenied:
return ErrAccessDenied
case TooLarge:
return ErrTooLarge
case DeviceUnavailable:
return ErrDeviceUnavailable
case Timeout:
return ErrTimeout
default:
return ErrError
}
}