mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 20:19:17 +08:00
Refactoring. Move plugin related work to Wox.Core
This commit is contained in:
parent
d9b2863382
commit
890397bae7
17
Wox.Core/Exception/WoxCritialException.cs
Normal file
17
Wox.Core/Exception/WoxCritialException.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Core.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Represent exceptions that wox can't handle and MUST close running Wox.
|
||||
/// </summary>
|
||||
public class WoxCritialException : WoxException
|
||||
{
|
||||
public WoxCritialException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
14
Wox.Core/Exception/WoxException.cs
Normal file
14
Wox.Core/Exception/WoxException.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace Wox.Core.Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Base Wox Exceptions
|
||||
/// </summary>
|
||||
public class WoxException : System.Exception
|
||||
{
|
||||
public WoxException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Wox.Infrastructure.Exceptions
|
||||
namespace Wox.Core.Exception
|
||||
{
|
||||
public class WoxHttpException :WoxException
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
namespace Wox.Infrastructure.Exceptions
|
||||
namespace Wox.Core.Exception
|
||||
{
|
||||
public class WoxJsonRPCException : WoxException
|
||||
{
|
@ -44,7 +44,7 @@ namespace Wox.Core.Plugin
|
||||
plugins.Add(pair);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Error(string.Format("Couldn't load plugin {0}: {1}", metadata.Name, e.Message));
|
||||
#if (DEBUG)
|
||||
|
@ -6,7 +6,6 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Exceptions;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Plugin;
|
||||
|
||||
@ -73,7 +72,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
return results;
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Error(e.Message);
|
||||
}
|
||||
@ -90,7 +89,7 @@ namespace Wox.Core.Plugin
|
||||
{
|
||||
methodInfo.Invoke(PluginManager.API, parameters);
|
||||
}
|
||||
catch (Exception)
|
||||
catch (System.Exception)
|
||||
{
|
||||
#if (DEBUG)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace Wox.Core.Plugin
|
||||
|
||||
return jsonRPCPluginMetadatas.Select(metadata => new PluginPair()
|
||||
{
|
||||
Plugin = jsonRPCPlugin,
|
||||
Plugin = new T(), //every JsonRPC plugin should has its own plugin instance
|
||||
Metadata = metadata
|
||||
}).ToList();
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Exceptions;
|
||||
using Wox.Core.Exception;
|
||||
using Wox.Infrastructure.Logger;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
using Wox.Plugin;
|
||||
@ -91,7 +91,7 @@ namespace Wox.Core.Plugin
|
||||
metadata.PluginType = PluginType.User;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (System.Exception)
|
||||
{
|
||||
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||
Log.Warn(error);
|
||||
|
@ -114,12 +114,12 @@ namespace Wox.Core.Plugin
|
||||
metadata.PluginType = PluginType.User;
|
||||
metadata.PluginDirectory = pluginDirectory;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (System.Exception)
|
||||
{
|
||||
string error = string.Format("Parse plugin config {0} failed: json format is not valid", configPath);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw new Exception(error);
|
||||
throw new System.Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
@ -132,7 +132,7 @@ namespace Wox.Core.Plugin
|
||||
metadata.Language);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw new Exception(error);
|
||||
throw new System.Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
@ -143,7 +143,7 @@ namespace Wox.Core.Plugin
|
||||
metadata.ExecuteFilePath);
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw new Exception(error);
|
||||
throw new System.Exception(error);
|
||||
}
|
||||
#endif
|
||||
return null;
|
||||
|
@ -30,7 +30,7 @@ namespace Wox.Core.Plugin.QueryDispatcher
|
||||
List<Result> results = userPlugin.Plugin.Query(query) ?? new List<Result>();
|
||||
PluginManager.API.PushResults(query,userPlugin.Metadata,results);
|
||||
}
|
||||
catch (Exception queryException)
|
||||
catch (System.Exception queryException)
|
||||
{
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", userPlugin.Metadata.Name,
|
||||
queryException.Message));
|
||||
|
@ -49,6 +49,10 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Exception\WoxCritialException.cs" />
|
||||
<Compile Include="Exception\WoxException.cs" />
|
||||
<Compile Include="Exception\WoxHttpException.cs" />
|
||||
<Compile Include="Exception\WoxJsonRPCException.cs" />
|
||||
<Compile Include="Plugin\PluginInstaller.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\IQueryDispatcher.cs" />
|
||||
<Compile Include="Plugin\QueryDispatcher\QueryDispatcher.cs" />
|
||||
|
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Wox.Infrastructure.Exceptions
|
||||
{
|
||||
public class WoxException : Exception
|
||||
{
|
||||
public WoxException(string msg)
|
||||
: base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -56,9 +56,6 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Exceptions\WoxException.cs" />
|
||||
<Compile Include="Exceptions\WoxHttpException.cs" />
|
||||
<Compile Include="Exceptions\WoxJsonRPCException.cs" />
|
||||
<Compile Include="Http\HttpProxy.cs" />
|
||||
<Compile Include="Logger\Log.cs" />
|
||||
<Compile Include="PeHeaderReader.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user