Esempio n. 1
0
        /// <summary>
        /// Is called if something went wrong with the API.
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/> contains the API where the error occured.</param>
        /// <param name="e">The e<see cref="EventArgs"/> contain an error type and an error message.</param>
        private void Api_OnApiError(object sender, OnApiErrorEventArgs e)
        {
            IApi api = (IApi)sender;

            if (e.ErrorType == ErrorType.TooManyRequests)
            {
                this.DisableApi(api);
                MessageBox.Show("Die erlaubte Anzahl an Aufrufen dieser API wurde überschritten! \nAPI deaktiviert.", api.ApiInfo.ApiName, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (e.ErrorType == ErrorType.Unauthorized)
            {
                this.DisableApi(api);
                MessageBox.Show("API Key ungültig! \nAPI deaktiviert.", api.ApiInfo.ApiName, MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (e.ErrorType == ErrorType.BadRequest || e.ErrorType == ErrorType.General)
            {
                this.DisableApi(api);
                MessageBox.Show("Fehler: " + e.ErrorMessage + "\nAPI deaktiviert.", api.ApiInfo.ApiName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Fires the OnApiError event.
 /// </summary>
 /// <param name="eventArgs">The eventArgs<see cref="OnApiErrorEventArgs"/></param>
 protected void FireOnApiError(OnApiErrorEventArgs eventArgs)
 {
     this.OnApiError?.Invoke(this, eventArgs);
 }