Display results from Piscal processing
Error handling for Piscal processing
This commit is contained in:
@@ -8,5 +8,6 @@ namespace LeafWeb.Core.Remote
|
||||
PiscalStatus GetLeafInputFileStatus(PiscalLeafInputFile file);
|
||||
IEnumerable<PiscalLeafOutputFile> RetrieveLeafOutput(PiscalLeafInputFile file);
|
||||
void CleanupLeafProcess(PiscalLeafInputFile file);
|
||||
string GetErrorMessage(PiscalLeafInputFile file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace LeafWeb.Core.Remote
|
||||
|
||||
private const string StatusSuccess = "success";
|
||||
private const string StatusRunning = "running";
|
||||
private const string StatusNotStarted = "not started";
|
||||
private const string StatusError = "error";
|
||||
|
||||
public PiscalSshClient(string connectionString)
|
||||
@@ -62,7 +63,7 @@ namespace LeafWeb.Core.Remote
|
||||
ssh.Disconnect();
|
||||
|
||||
if (command.ExitStatus != 0)
|
||||
throw new PiscalClientException(command.Error);
|
||||
throw new PiscalClientException(command.Result);
|
||||
|
||||
Console.Write(command.Result);
|
||||
}
|
||||
@@ -78,6 +79,8 @@ namespace LeafWeb.Core.Remote
|
||||
return PiscalStatus.Running;
|
||||
case StatusSuccess:
|
||||
return PiscalStatus.Success;
|
||||
case StatusNotStarted:
|
||||
return PiscalStatus.NotStarted;
|
||||
default:
|
||||
return PiscalStatus.Error;
|
||||
}
|
||||
@@ -94,7 +97,7 @@ namespace LeafWeb.Core.Remote
|
||||
ssh.Disconnect();
|
||||
|
||||
if (command.ExitStatus != 0)
|
||||
throw new PiscalClientException(command.Error);
|
||||
throw new PiscalClientException(command.Result);
|
||||
|
||||
return command.Result
|
||||
.SplitNewLine()
|
||||
@@ -137,6 +140,16 @@ namespace LeafWeb.Core.Remote
|
||||
}
|
||||
}
|
||||
|
||||
public string GetErrorMessage(PiscalLeafInputFile file)
|
||||
{
|
||||
var status = GetLeafInputStatusRaw(file);
|
||||
if (status[0] != StatusError)
|
||||
return string.Empty;
|
||||
|
||||
var errorLines = status.Skip(1).ToArray();
|
||||
return errorLines.Join(Environment.NewLine);
|
||||
}
|
||||
|
||||
public void CleanupLeafProcess(PiscalLeafInputFile file)
|
||||
{
|
||||
var status = GetLeafInputStatusRaw(file);
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace LeafWeb.Core.Remote
|
||||
{
|
||||
Running,
|
||||
Success,
|
||||
NotStarted,
|
||||
Error
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -50,5 +51,10 @@ namespace LeafWeb.Core.Utility
|
||||
{
|
||||
return Regex.Replace(path, @".*/([^/]*$)", "$1");
|
||||
}
|
||||
|
||||
public static string Join<T>(this IEnumerable<T> enumerable, string separator)
|
||||
{
|
||||
return string.Join(separator, enumerable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user