/// <summary> /// Logs an exception to hub client and any provided log exception delegate. /// </summary> /// <param name="ex">Exception to log.</param> /// <param name="logToClient">Determines if message should be logged to hub client.</param> /// <remarks> /// When <paramref name="logToClient"/> is <c>true</c>, function will /// call "sendErrorMessage" Javascript hub client function if defined. /// </remarks> protected void LogException(Exception ex, bool logToClient = true) { // Send exception to hub client if (logToClient) { ClientScript?.sendErrorMessage(ex.Message, -1); } // Send exception to program host m_logExceptionFunction?.Invoke(ex); }
/// <summary> /// Logs an exception to hub client and any provided log exception delegate. /// </summary> /// <param name="ex">Exception to log.</param> /// <param name="logToClient">Determines if message should be logged to hub client.</param> /// <remarks> /// When <paramref name="logToClient"/> is <c>true</c>, function will /// call "sendErrorMessage" Javascript hub client function if defined. /// </remarks> protected void LogException(Exception ex, bool logToClient = true) { try { // Send exception to hub client if (logToClient) { ClientScript?.sendErrorMessage(ex.Message, -1); } } catch (NullReferenceException) { // Attempting to access this property from self-created hub instance, i.e., a manually created // instance instead of one created by SignalR, will cause a null-reference exception. } // Send exception to program host LogExceptionFunction?.Invoke(ex); }