improved error handling
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
it has now a feature to add and remove mpv.net to and from the Path
|
||||
environment variable and the OS default apps settings can be opened (Win 10 only)
|
||||
- Error messages are shown when unknown scripts and extensions are found in the startup folder
|
||||
because user scripts are supposed to be located in the config folder instead
|
||||
because user scripts and extensions are supposed to be located in the config folder instead
|
||||
|
||||
### 5.0
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ScriptingExtension // the file name of extensions must end with 'Exten
|
||||
|
||||
if (Directory.Exists(Application.StartupPath + "\\scripts"))
|
||||
foreach (string file in Directory.GetFiles(Application.StartupPath + "\\scripts", "*.cs"))
|
||||
Msg.ShowError("Failed to load script.", "Only scripts that ship with mpv.net are allowed in <startup>\\scripts.\n\nUser scripts have to use <config folder>\\scripts.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + file);
|
||||
App.UnknownModule(file);
|
||||
|
||||
if (scriptFiles.Count == 0) return;
|
||||
CSScriptLibrary.CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace mpvnet
|
||||
if (knownExtensions.Contains(Path.GetFileName(path)))
|
||||
catalog.Catalogs.Add(new DirectoryCatalog(path, "*Extension.dll"));
|
||||
else
|
||||
Msg.ShowError("Failed to load extension", "Only extensions that ship with mpv.net are allowed in <startup>\\extensions.\n\nUser extensions have to use <config folder>\\extensions.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + path);
|
||||
App.UnknownModule(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,11 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnknownModule(string path)
|
||||
{
|
||||
Msg.ShowError("Failed to load script or extension", "Only scripts and extensions that ship with mpv.net are allowed in <startup>\\scripts or <startup>\\extensions.\n\nUser scripts or extensions have to use <config folder>\\scripts or <config folder>\\extensions.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + path);
|
||||
}
|
||||
|
||||
public static bool ProcessProperty(string name, string value)
|
||||
{
|
||||
switch (name) // return true instead of break!
|
||||
|
||||
@@ -213,8 +213,6 @@ namespace mpvnet
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnknownScriptError(string path) => Msg.ShowError("Failed to load script", "Only scripts that ship with mpv.net are allowed in <startup>\\scripts.\n\nUser scripts have to use <config folder>\\scripts.\n\nNever copy a new mpv.net version over a old mpv.net version.\n\nNever install a new mpv.net version on top of a old mpv.net version.\n\n" + path);
|
||||
|
||||
public static void LoadMpvScripts()
|
||||
{
|
||||
string[] startupScripts = Directory.GetFiles(Application.StartupPath + "\\Scripts");
|
||||
@@ -224,7 +222,7 @@ namespace mpvnet
|
||||
if (KnownScripts.Contains(Path.GetFileName(path)))
|
||||
commandv("load-script", $"{path}");
|
||||
else
|
||||
UnknownScriptError(path);
|
||||
App.UnknownModule(path);
|
||||
}
|
||||
|
||||
public static string[] KnownScripts { get; } = { "osc-visibility.js", "show-playlist.js", "seek-show-position.py" };
|
||||
@@ -243,7 +241,7 @@ namespace mpvnet
|
||||
PowerShellScript.Init(path);
|
||||
}
|
||||
else
|
||||
UnknownScriptError(path);
|
||||
App.UnknownModule(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user