12
error.go
12
error.go
@@ -4,6 +4,7 @@ import (
|
||||
"C"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/crewjam/errset"
|
||||
)
|
||||
@@ -32,8 +33,8 @@ func (e libraryError) Error() string {
|
||||
e.Message)
|
||||
}
|
||||
|
||||
//export onError
|
||||
func onError(file *C.char, line C.int, funcName *C.char, errorObject *C.char, errorSubject *C.char, reason C.int, msg *C.char) {
|
||||
//export onXmlsecError
|
||||
func onXmlsecError(file *C.char, line C.int, funcName *C.char, errorObject *C.char, errorSubject *C.char, reason C.int, msg *C.char) {
|
||||
err := libraryError{
|
||||
FuncName: C.GoString(funcName),
|
||||
FileName: C.GoString(file),
|
||||
@@ -46,6 +47,13 @@ func onError(file *C.char, line C.int, funcName *C.char, errorObject *C.char, er
|
||||
globalErrors[threadID] = append(globalErrors[threadID], err)
|
||||
}
|
||||
|
||||
//export onXmlError
|
||||
func onXmlError(msg *C.char) {
|
||||
threadID := getThreadID()
|
||||
globalErrors[threadID] = append(globalErrors[threadID],
|
||||
fmt.Errorf("%s", strings.TrimSuffix(C.GoString(msg), "\n")))
|
||||
}
|
||||
|
||||
// startProcessingXML is called whenever we enter a function exported by this package.
|
||||
// It locks the current goroutine to the current thread and establishes a thread-local
|
||||
// error object. If the library later calls onError then the error will be appended
|
||||
|
||||
Reference in New Issue
Block a user