Beispiel #1
0
 private void HandleError(ContactPluginData plugin, Exception e, PluginData.PluginDataState failed_state = PluginData.PluginDataState.DISABLED_ERROR)
 {
     Utils.PluginLog(PluginManagerName(), "Plugin \"" + plugin.contact_plugin.ProviderName() + "\" had an error Due to: " + e.Message);
     plugin.state      = failed_state;
     plugin.last_error = e.Message;
     active_plugin     = null;
 }
Beispiel #2
0
        private void HandleError(PluginError error, PluginData.PluginDataState failed_state = PluginData.PluginDataState.DISABLED_ERROR)
        {
            if (error.plugin == null)
            {
                error.plugin = error.device.plugin;
            }
            if ((DateTime.Now - error.plugin.last_error_time).TotalSeconds > 60 * 5)              //if no errors for 5 minutes reset error count
            {
                error.plugin.error_tries_left = DEFAULT_PLUGIN_RETRIES;
            }

            error.plugin.last_error_time = DateTime.Now;
            error.plugin.last_error      = error.exception.Message;
            String restart_msg = error.plugin.error_tries_left > 0 ? " will try to restart/init it " + error.plugin.error_tries_left + " more times" : " will not be restarting it";

            Utils.PluginLog(PluginManagerName(), "Plugin " + error.plugin.plugin.ProviderName() + " had an error due to: " + error.exception.Message + "\n" + restart_msg);
            List <DeviceData> to_remove = new List <DeviceData>();

            lock (devices_lock) {
                foreach (DeviceData device in devices)
                {
                    if (device.plugin == error.plugin)
                    {
                        try {
                            device.device.SetActive(false);
                        }
                        catch (Exception) {
                            Utils.PluginLog(PluginManagerName(), "While handling error wasn't able to deactivate device, not a major issue");
                        }
                        to_remove.Add(device);
                    }
                }
            }
            lock (devices_lock) {
                foreach (DeviceData device in to_remove)
                {
                    devices.Remove(device);
                }
            }
            error.plugin.plugin.Terminate();
            if (error.plugin.error_tries_left-- > 0)
            {
                DelayedFunction.DelayedCall("IHeadsetPlugin_PluginStart_ " + error.plugin.plugin.ProviderName(), () => init_plugin(error.plugin), 1000);                //give it a second
            }
            else
            {
                error.plugin.state = failed_state;
            }
        }