Init project
This commit is contained in:
29
RobotApp.VDA5050/VDA5050Helper.cs
Normal file
29
RobotApp.VDA5050/VDA5050Helper.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using RobotApp.VDA5050.State;
|
||||
using System.Text;
|
||||
|
||||
namespace RobotApp.VDA5050;
|
||||
|
||||
public class VDA5050Helper
|
||||
{
|
||||
public static string ConvertErrorDetail(IEnumerable<Error> errors)
|
||||
{
|
||||
string errorsType = "";
|
||||
foreach (var error in errors)
|
||||
{
|
||||
if (error == errors.Last()) errorsType += $"{error.ErrorType}";
|
||||
else errorsType += $"{error.ErrorType}, ";
|
||||
}
|
||||
StringBuilder errorStr = new($"Robot có lỗi: [{errorsType}]\n");
|
||||
foreach (var error in errors)
|
||||
{
|
||||
string errorDes = $"- {error.ErrorType}: {error.ErrorDescription}\n";
|
||||
errorStr.Append(errorDes.PadLeft(errorDes.Length + 3));
|
||||
foreach (var refer in error.ErrorReferences)
|
||||
{
|
||||
string errorRefer = $"+ {refer.ReferenceKey}: {refer.ReferenceValue}\n";
|
||||
errorStr.Append(errorRefer.PadLeft(errorRefer.Length + 9));
|
||||
}
|
||||
}
|
||||
return !errors.Any() ? "" : errorStr.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user