Skip to content
Snippets Groups Projects
Commit d6587bf8 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

ModuleException and use in ModuleI3Status

parent ee9a523c
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,9 @@ namespace i3csstatus {
Color? color=null
);
class ModuleException: Exception
{
}
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple = true)]
public class ModuleName : System.Attribute
{
......@@ -82,6 +85,13 @@ namespace i3csstatus {
[ModuleName("i3status")]
class ModuleI3Status: Module
{
class ModuleI3StatusException: ModuleException
{
public override string ToString()
{
return $"I3Status don't work correctly.";
}
}
string name;
string configuration;
Element[] elements;
......@@ -131,9 +141,13 @@ namespace i3csstatus {
public override void GetBegin()
{
process.KillBySignal(10);
string str = process.StandardOutput.ReadLine()[1..];
Console.WriteLine(str);
JsonArray json = JsonObject.Parse(str).AsArray();
string line = process.StandardOutput.ReadLine();
if(line == null)
{
throw new ModuleI3StatusException();
}
Console.WriteLine(line[1..]);
JsonArray json = JsonObject.Parse(line[1..]).AsArray();
if(json.Count != modules.Count)
throw new Exception("Parse i3status error");
for(int i=0;i<modules.Count;i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment