/
errors.go
49 lines (43 loc) · 1.17 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
package sound
import "fmt"
// Errorcodes
const (
EDEVICE = 1
ECHANNEL = 2
EFREQ = 3
EMONO = 4
ESTEREO = 5
EAMPLITUDE = 6
EFUNCTION = 7
EINTERNAL = 8
)
// map containing the string representation of the Errorcode
var ErrorName = map[int]string{
EDEVICE: "EDEVICE",
ECHANNEL: "ECHANNEL",
EFREQ: "EFREQ",
EMONO: "EMONO",
ESTEREO: "ESTEREO",
EAMPLITUDE: "EAMPLITUDE",
EFUNCTION: "EFUNCTION",
EINTERNAL: "EINTERNAL",
}
// map containing the description of the Errorcode
var ErrorDescription = map[int]string{
EDEVICE: "Unknown Device",
ECHANNEL: "Channel unknown, not defined or contains invalid data",
EFREQ: "Invalid Frequency",
EMONO: "A Mono Stream takes exactly one Channel",
ESTEREO: "A Stereo Stream takes exactly two Channels",
EAMPLITUDE: "Invalid Amplitude",
EFUNCTION: "Test Function does not exist",
EINTERNAL: "Internal Error",
}
type SoundbenchError struct {
Errorcode int
Unit string
AdditionalInfo string
}
func (e *SoundbenchError) Error() string {
return fmt.Sprintf("ERROR %s: %s - %s (%s)", ErrorName[e.Errorcode], e.Unit, ErrorDescription[e.Errorcode], e.AdditionalInfo)
}