private static void ThrowIfGnuTlsError(int res, string method) { if (res < 0) { var errorName = Encoder.Instance.PtrToString(NativeMethodsLinux.gnutls_strerror_name(res)); var errorMessage = Encoder.Instance.PtrToString(NativeMethodsLinux.gnutls_strerror(res)); throw new LdapException( new LdapExceptionData($"GnuTls error name: {errorName}. GnuTls error message: {errorMessage} Result: {res}. Method: {method}")); } }