VarFromHandleTry version returns the error explicitly, for use when error can be processed
(h CGoHandle, typnm string)
| 187 | // VarFromHandleTry version returns the error explicitly, |
| 188 | // for use when error can be processed |
| 189 | func VarFromHandleTry(h CGoHandle, typnm string) (interface{}, error) { |
| 190 | if h < 1 { |
| 191 | return nil, fmt.Errorf("gopy: nil handle") |
| 192 | } |
| 193 | mu.RLock() |
| 194 | defer mu.RUnlock() |
| 195 | v, has := handles[GoHandle(h)] |
| 196 | if !has { |
| 197 | err := fmt.Errorf("gopy: variable handle not registered: " + strconv.FormatInt(int64(h), 10)) |
| 198 | // TODO: need to get access to this: |
| 199 | // C.PyErr_SetString(C.PyExc_TypeError, C.CString(err.Error())) |
| 200 | return nil, err |
| 201 | } |
| 202 | return v, nil |
| 203 | } |
| 204 | |
| 205 | // NumHandles returns the number of handles in use. |
| 206 | func NumHandles() int { |
no test coverage detected