remove custom exception

This commit is contained in:
bao-qian
2017-01-30 00:26:11 +00:00
parent 052048ad4c
commit 974efc55ac
12 changed files with 62 additions and 121 deletions

View File

@@ -43,31 +43,43 @@ namespace Wox.Core.Resource
private Language GetLanguageByLanguageCode(string languageCode)
{
Language language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.ToLower() == languageCode.ToLower());
var lowercase = languageCode.ToLower();
var language = AvailableLanguages.GetAvailableLanguages().FirstOrDefault(o => o.LanguageCode.ToLower() == lowercase);
if (language == null)
{
throw new WoxI18nException("Invalid language code:" + languageCode);
Log.Error($"|Internationalization.GetLanguageByLanguageCode|Language code can't be found <{languageCode}>");
return AvailableLanguages.English;
}
else
{
return language;
}
return language;
}
public void ChangeLanguage(Language language)
{
if (language == null) throw new WoxI18nException("language can't be null");
string path = GetLanguagePath(language);
if (string.IsNullOrEmpty(path))
if (language != null)
{
path = GetLanguagePath(AvailableLanguages.English);
if (string.IsNullOrEmpty(path))
string path = GetLanguagePath(language);
if (!string.IsNullOrEmpty(path))
{
throw new Exception("Change Language failed");
Settings.Language = language.LanguageCode;
ResourceMerger.UpdateResource(this);
}
else
{
Log.Error($"|Internationalization.ChangeLanguage|Language path can't be found <{path}>");
path = GetLanguagePath(AvailableLanguages.English);
if (string.IsNullOrEmpty(path))
{
Log.Error($"|Internationalization.ChangeLanguage|Default english language path can't be found <{path}>");
}
}
}
Settings.Language = language.LanguageCode;
ResourceMerger.UpdateResource(this);
else
{
Log.Error("|Internationalization.ChangeLanguage|Language can't be null");
}
}

View File

@@ -6,6 +6,7 @@ using System.Windows;
using Wox.Core.Plugin;
using Wox.Plugin;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger;
namespace Wox.Core.Resource
{
@@ -54,7 +55,7 @@ namespace Wox.Core.Resource
}
else
{
throw new WoxPluginException(plugin.Metadata.Name, "Can't find plugin location.");
Log.Error($"|ResourceMerger.UpdatePluginLanguages|Can't find plugin path <{location}> for <{plugin.Metadata.Name}>");
}
}