Esempio n. 1
0
File: err.go Progetto: gbbr/textmate
func raise(err error) {
	var val *C.PyObject
	var exc = C.PyExc_Exception

	e, ok := err.(*Error)
	if ok {
		exc = c(e.Kind)
		val = c(e.Value)
	} else {
		v, _ := NewUnicode(err.Error())
		val = c(v)
	}

	C.PyErr_SetObject(exc, val)
}
Esempio n. 2
0
func Raise(err error) {

	var val *C.PyObject
	var exc = C.PyExc_Exception

	e, ok := err.(*Error)
	if ok {
		exc = e.Kind.c()
		val = e.Value.c()
	} else {
		v := NewString(errors.Detail(err))
		val = v.c()
		defer C.decref(val)
	}
	C.PyErr_SetObject(exc, val)
}
Esempio n. 3
0
// void PyErr_SetObject(PyObject *type, PyObject *value)
// This function is similar to PyErr_SetString() but lets you specify an arbitrary Python object for the “value” of the exception.
func PyErr_SetObject(typ, value *PyObject) {
	C.PyErr_SetObject(topy(typ), topy(value))
}