 
 private class ParserContext {
     var count: Int
+    var errors: [Error]
     var handler: TripleHandler
     var env: OpaquePointer!
     

        serd_env_free(env)
        serd_node_free(&base)
        
        if status != SERD_SUCCESS {
            throw RDFParserError.parseError("Failed to parse file using serd")
        }

        return context.count
    }
}


let serd_end_sink : @convention(c) (UnsafeMutableRawPointer?, UnsafePointer<SerdNode>?) -> SerdStatus = { (handle, node) -> SerdStatus in return SERD_SUCCESS }

let serd_error_sink : @convention(c) (UnsafeMutableRawPointer?, UnsafePointer<SerdError>?) -> SerdStatus = { (handle, error) in
    if let error = error {
        let e = error.pointee
        let filename = String(cString: e.filename)
        let fmt = String(cString: e.fmt)
        let msg = "serd error while parsing \(filename): \(fmt))"
        Logger.shared.error(msg)
        if let ptr = handle?.assumingMemoryBound(to: ParserContext.self) {
            let ctx = ptr.pointee
            ctx.errors.append(RDFParser.RDFParserError.parseError(msg))
        }
    } else {
        Logger.shared.error("serd error during parsing")
    }
