forked from jiyeyuran/mediasoup-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
53 lines (43 loc) · 1.04 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
package mediasoup
import (
"fmt"
)
type TypeError struct {
err error
}
func NewTypeError(format string, args ...interface{}) error {
return TypeError{
err: fmt.Errorf(format, args...),
}
}
func (e TypeError) Error() string {
return e.err.Error()
}
// UnsupportedError indicating not support for something.
type UnsupportedError struct {
name string
message string
}
func NewUnsupportedError(format string, args ...interface{}) error {
return UnsupportedError{
name: "UnsupportedError",
message: fmt.Sprintf(format, args...),
}
}
func (e UnsupportedError) Error() string {
return fmt.Sprintf("%s:%s", e.name, e.message)
}
// InvalidStateError produced when calling a method in an invalid state.
type InvalidStateError struct {
name string
message string
}
func NewInvalidStateError(format string, args ...interface{}) error {
return UnsupportedError{
name: "InvalidStateError",
message: fmt.Sprintf(format, args...),
}
}
func (e InvalidStateError) Error() string {
return fmt.Sprintf("%s:%s", e.name, e.message)
}