private void ValidateConfiguration() { if (this._isInitialized) { return; } if (this._config == null) { RollbarException exception = new RollbarException(InternalRollbarError.ConfigurationError, "Rollbar configuration is never assigned!"); throw exception; } IValidatable?validatable = this._config as IValidatable; Validator.Validate(validatable, InternalRollbarError.ConfigurationError, "Failed to configure using invalid configuration prototype!"); }
/// <summary> /// Validates the configuration. /// </summary> /// <param name="rollbarConfig">The rollbar configuration.</param> private void ValidateConfiguration(IRollbarConfig rollbarConfig) { IValidatable validatableConfig = rollbarConfig as IValidatable; if (validatableConfig != null) { var failedValidationRules = validatableConfig.Validate(); if (failedValidationRules.Count > 0) { var exception = new RollbarException( InternalRollbarError.ConfigurationError, "Failed to configure using invalid configuration prototype!" ); exception.Data[nameof(failedValidationRules)] = failedValidationRules.ToArray(); throw exception; } } }
/// <summary> /// Validates the configuration. /// </summary> /// <param name="rollbarConfig">The rollbar configuration.</param> private void ValidateConfiguration(IRollbarConfig rollbarConfig) { switch (rollbarConfig) { case IValidatable v: var failedValidationRules = v.Validate(); if (failedValidationRules.Count > 0) { var exception = new RollbarException( InternalRollbarError.ConfigurationError, "Failed to configure using invalid configuration prototype!" ); exception.Data[nameof(failedValidationRules)] = failedValidationRules.ToArray(); throw exception; } break; } }
/// <summary> /// Reports the specified rollbar logger. /// </summary> /// <param name="rollbarLogger">The rollbar logger.</param> /// <param name="dataObject">The data object.</param> /// <param name="rollbarError">The rollbar error.</param> /// <param name="message">The message.</param> /// <param name="exception">The exception.</param> public static void Report( RollbarLogger rollbarLogger, object dataObject, InternalRollbarError rollbarError, string message, Exception exception ) { var rollbarException = new RollbarException(rollbarError, message ?? rollbarError.ToString(), exception); var rollbarEvent = new InternalErrorEventArgs(rollbarLogger, dataObject, rollbarException, rollbarException.Message); if (rollbarLogger != null) { rollbarLogger.OnRollbarEvent(rollbarEvent); } else { RollbarQueueController.Instance.OnRollbarEvent(rollbarEvent); } }