forked from pion/mediadevices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
45 lines (39 loc) · 742 Bytes
/
error.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
package openh264
import (
"fmt"
)
import "C"
type eResult int
const (
retSuccess eResult = 0
retFailed eResult = -1
retInvalidParam eResult = -2
retOutOfMemory eResult = -3
retNotSupported eResult = -4
retUnexpected eResult = -5
retNeedReinit eResult = -6
)
func (e eResult) Error() string {
switch e {
case retFailed:
return "failed"
case retInvalidParam:
return "invalid param"
case retOutOfMemory:
return "out of memory"
case retNotSupported:
return "not supported"
case retUnexpected:
return "unexpected"
case retNeedReinit:
return "need reinit"
default:
return fmt.Sprintf("unknown error (%d)", e)
}
}
func errResult(e C.int) error {
if e == 0 {
return nil
}
return eResult(e)
}