@@ -24,43 +24,43 @@ const (
24
24
25
25
type ActiveConnection interface {
26
26
// GetConnection gets connection object of the connection.
27
- GetConnection () Connection
27
+ GetConnection () ( Connection , error )
28
28
29
29
// GetSpecificObject gets a specific object associated with the active connection.
30
- GetSpecificObject () AccessPoint
30
+ GetSpecificObject () ( AccessPoint , error )
31
31
32
32
// GetID gets the ID of the connection.
33
- GetID () string
33
+ GetID () ( string , error )
34
34
35
35
// GetUUID gets the UUID of the connection.
36
- GetUUID () string
36
+ GetUUID () ( string , error )
37
37
38
38
// GetType gets the type of the connection.
39
- GetType () string
39
+ GetType () ( string , error )
40
40
41
41
// GetDevices gets array of device objects which are part of this active connection.
42
- GetDevices () []Device
42
+ GetDevices () ( []Device , error )
43
43
44
44
// GetState gets the state of the connection.
45
- GetState () uint32
45
+ GetState () ( uint32 , error )
46
46
47
47
// GetStateFlags gets the state flags of the connection.
48
- GetStateFlags () uint32
48
+ GetStateFlags () ( uint32 , error )
49
49
50
50
// GetDefault gets the default IPv4 flag of the connection.
51
- GetDefault () bool
51
+ GetDefault () ( bool , error )
52
52
53
53
// GetIP4Config gets the IP4Config of the connection.
54
- GetIP4Config () IP4Config
54
+ GetIP4Config () ( IP4Config , error )
55
55
56
56
// GetDHCP4Config gets the DHCP4Config of the connection.
57
- GetDHCP4Config () DHCP4Config
57
+ GetDHCP4Config () ( DHCP4Config , error )
58
58
59
59
// GetVPN gets the VPN flag of the connection.
60
- GetVPN () bool
60
+ GetVPN () ( bool , error )
61
61
62
62
// GetMaster gets the master device of the connection.
63
- GetMaster () Device
63
+ GetMaster () ( Device , error )
64
64
}
65
65
66
66
func NewActiveConnection (objectPath dbus.ObjectPath ) (ActiveConnection , error ) {
@@ -72,90 +72,113 @@ type activeConnection struct {
72
72
dbusBase
73
73
}
74
74
75
- func (a * activeConnection ) GetConnection () Connection {
76
- path := a .getObjectProperty (ActiveConnectionProperyConnection )
75
+ func (a * activeConnection ) GetConnection () (Connection , error ) {
76
+ path , err := a .getObjectProperty (ActiveConnectionProperyConnection )
77
+ if err != nil {
78
+ return nil , err
79
+ }
77
80
con , err := NewConnection (path )
78
81
if err != nil {
79
- panic ( err )
82
+ return nil , err
80
83
}
81
- return con
84
+ return con , nil
82
85
}
83
86
84
- func (a * activeConnection ) GetSpecificObject () AccessPoint {
85
- path := a .getObjectProperty (ActiveConnectionProperySpecificObject )
87
+ func (a * activeConnection ) GetSpecificObject () (AccessPoint , error ) {
88
+ path , err := a .getObjectProperty (ActiveConnectionProperySpecificObject )
89
+ if err != nil {
90
+ return nil , err
91
+ }
86
92
ap , err := NewAccessPoint (path )
87
93
if err != nil {
88
- panic ( err )
94
+ return nil , err
89
95
}
90
- return ap
96
+ return ap , nil
91
97
}
92
98
93
- func (a * activeConnection ) GetID () string {
99
+ func (a * activeConnection ) GetID () ( string , error ) {
94
100
return a .getStringProperty (ActiveConnectionProperyID )
95
101
}
96
102
97
- func (a * activeConnection ) GetUUID () string {
103
+ func (a * activeConnection ) GetUUID () ( string , error ) {
98
104
return a .getStringProperty (ActiveConnectionProperyUUID )
99
105
}
100
106
101
- func (a * activeConnection ) GetType () string {
107
+ func (a * activeConnection ) GetType () ( string , error ) {
102
108
return a .getStringProperty (ActiveConnectionProperyType )
103
109
}
104
110
105
- func (a * activeConnection ) GetDevices () []Device {
106
- paths := a .getSliceObjectProperty (ActiveConnectionProperyDevices )
111
+ func (a * activeConnection ) GetDevices () ([]Device , error ) {
112
+ paths , err := a .getSliceObjectProperty (ActiveConnectionProperyDevices )
113
+ if err != nil {
114
+ return nil , err
115
+ }
107
116
devices := make ([]Device , len (paths ))
108
- var err error
109
117
for i , path := range paths {
110
118
devices [i ], err = DeviceFactory (path )
111
119
if err != nil {
112
- panic ( err )
120
+ return nil , err
113
121
}
114
122
}
115
- return devices
123
+ return devices , nil
116
124
}
117
125
118
- func (a * activeConnection ) GetState () uint32 {
126
+ func (a * activeConnection ) GetState () ( uint32 , error ) {
119
127
return a .getUint32Property (ActiveConnectionProperyState )
120
128
}
121
129
122
- func (a * activeConnection ) GetStateFlags () uint32 {
130
+ func (a * activeConnection ) GetStateFlags () ( uint32 , error ) {
123
131
return a .getUint32Property (ActiveConnectionProperyStateFlags )
124
132
}
125
133
126
- func (a * activeConnection ) GetDefault () bool {
127
- b := a .getProperty (ActiveConnectionProperyDefault )
128
- return b .(bool )
134
+ func (a * activeConnection ) GetDefault () (bool , error ) {
135
+ b , err := a .getProperty (ActiveConnectionProperyDefault )
136
+ if err != nil {
137
+ return false , err
138
+ }
139
+ return b .(bool ), nil
129
140
}
130
141
131
- func (a * activeConnection ) GetIP4Config () IP4Config {
132
- path := a .getObjectProperty (ActiveConnectionProperyIP4Config )
142
+ func (a * activeConnection ) GetIP4Config () (IP4Config , error ) {
143
+ path , err := a .getObjectProperty (ActiveConnectionProperyIP4Config )
144
+ if err != nil {
145
+ return nil , err
146
+ }
133
147
r , err := NewIP4Config (path )
134
148
if err != nil {
135
- panic ( err )
149
+ return nil , err
136
150
}
137
- return r
151
+ return r , nil
138
152
}
139
153
140
- func (a * activeConnection ) GetDHCP4Config () DHCP4Config {
141
- path := a .getObjectProperty (ActiveConnectionProperyDHCP4Config )
154
+ func (a * activeConnection ) GetDHCP4Config () (DHCP4Config , error ) {
155
+ path , err := a .getObjectProperty (ActiveConnectionProperyDHCP4Config )
156
+ if err != nil {
157
+ return nil , err
158
+ }
142
159
r , err := NewDHCP4Config (path )
143
160
if err != nil {
144
- panic ( err )
161
+ return nil , err
145
162
}
146
- return r
163
+ return r , nil
147
164
}
148
165
149
- func (a * activeConnection ) GetVPN () bool {
150
- ret := a .getProperty (ActiveConnectionProperyVPN )
151
- return ret .(bool )
166
+ func (a * activeConnection ) GetVPN () (bool , error ) {
167
+ ret , err := a .getProperty (ActiveConnectionProperyVPN )
168
+ if err != nil {
169
+ return false , err
170
+ }
171
+ return ret .(bool ), nil
152
172
}
153
173
154
- func (a * activeConnection ) GetMaster () Device {
155
- path := a .getObjectProperty (ActiveConnectionProperyMaster )
174
+ func (a * activeConnection ) GetMaster () (Device , error ) {
175
+ path , err := a .getObjectProperty (ActiveConnectionProperyMaster )
176
+ if err != nil {
177
+ return nil , err
178
+ }
156
179
r , err := DeviceFactory (path )
157
180
if err != nil {
158
- panic ( err )
181
+ return nil , err
159
182
}
160
- return r
183
+ return r , nil
161
184
}
0 commit comments