From 2fd318fcbf8998036de9cb3bffaabff4a8fe5e25 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Tue, 26 May 2020 03:44:17 +0300 Subject: [PATCH] refactor logging in Core.Plugin.PluginInstaller --- Flow.Launcher.Core/Plugin/PluginInstaller.cs | 27 +++++--------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Flow.Launcher.Core/Plugin/PluginInstaller.cs b/Flow.Launcher.Core/Plugin/PluginInstaller.cs index df38ca608..efb239d7e 100644 --- a/Flow.Launcher.Core/Plugin/PluginInstaller.cs +++ b/Flow.Launcher.Core/Plugin/PluginInstaller.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.IO; using System.Windows; using ICSharpCode.SharpZipLib.Zip; using Newtonsoft.Json; using Flow.Launcher.Plugin; +using Flow.Launcher.Infrastructure.Logger; namespace Flow.Launcher.Core.Plugin { @@ -107,36 +108,20 @@ namespace Flow.Launcher.Core.Plugin metadata = JsonConvert.DeserializeObject(File.ReadAllText(configPath)); metadata.PluginDirectory = pluginDirectory; } - catch (Exception) + catch (Exception e) { - string error = $"Parse plugin config {configPath} failed: json format is not valid"; -#if (DEBUG) - { - throw new Exception(error); - } -#endif + Log.Exception($"|PluginInstaller.GetMetadataFromJson|plugin config {configPath} failed: invalid json format", e); return null; } - if (!AllowedLanguage.IsAllowed(metadata.Language)) { - string error = $"Parse plugin config {configPath} failed: invalid language {metadata.Language}"; -#if (DEBUG) - { - throw new Exception(error); - } -#endif + Log.Error($"|PluginInstaller.GetMetadataFromJson|plugin config {configPath} failed: invalid language {metadata.Language}"); return null; } if (!File.Exists(metadata.ExecuteFilePath)) { - string error = $"Parse plugin config {configPath} failed: ExecuteFile {metadata.ExecuteFilePath} didn't exist"; -#if (DEBUG) - { - throw new Exception(error); - } -#endif + Log.Error($"|PluginInstaller.GetMetadataFromJson|plugin config {configPath} failed: file {metadata.ExecuteFilePath} doesn't exist"); return null; }