Throw exception if failed to read press brake program.

This commit is contained in:
AJ
2018-11-01 09:54:03 -04:00
parent 6bc5cbf79e
commit 3574963b1e
2 changed files with 6 additions and 26 deletions

View File

@@ -45,14 +45,14 @@ namespace CincyLib.PressBrake
public static Program Read(string file)
{
var reader = new ProgramReader();
var success= reader.Read(file);
reader.Read(file);
return reader.Program;
}
public static Program Read(Stream stream)
{
var reader = new ProgramReader();
var success = reader.Read(stream);
reader.Read(stream);
return reader.Program;
}
}

View File

@@ -14,32 +14,14 @@ namespace CincyLib.PressBrake
Program = new Program();
}
public bool Read(string file)
public void Read(string file)
{
Stream stream = null;
var stream = File.OpenRead(file);
Program.FilePath = file;
var success = false;
try
{
stream = File.OpenRead(file);
success = Read(stream);
}
catch (SystemException ex)
{
Debug.WriteLine(ex.Message);
}
finally
{
if (stream != null)
stream.Close();
}
return success;
Read(stream);
}
public bool Read(Stream stream)
public void Read(Stream stream)
{
var xml = XDocument.Load(stream);
@@ -72,8 +54,6 @@ namespace CincyLib.PressBrake
var step = ReadStep(item);
Program.Steps.Add(step);
}
return true;
}
private ToolSetup ReadToolSetup(XElement x)