discsystem - handle some errors that werent handled before

This commit is contained in:
zeromus 2015-09-16 14:27:28 -05:00
parent 67d45dde10
commit 8f5059d53e
4 changed files with 25 additions and 8 deletions

View File

@ -270,7 +270,7 @@ namespace BizHawk.Client.Common
} }
if (discMountJob.OUT_ErrorLevel) if (discMountJob.OUT_ErrorLevel)
throw new InvalidOperationException(discMountJob.OUT_Log); throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log);
if(disc == null) if(disc == null)
throw new InvalidOperationException("Can't load one of the files specified in the M3U"); throw new InvalidOperationException("Can't load one of the files specified in the M3U");
@ -329,7 +329,7 @@ namespace BizHawk.Client.Common
} }
if (discMountJob.OUT_ErrorLevel) if (discMountJob.OUT_ErrorLevel)
throw new InvalidOperationException(discMountJob.OUT_Log); throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log);
var disc = discMountJob.OUT_Disc; var disc = discMountJob.OUT_Disc;
//----------- //-----------
@ -465,7 +465,7 @@ namespace BizHawk.Client.Common
} }
if (discMountJob.OUT_ErrorLevel) if (discMountJob.OUT_ErrorLevel)
throw new InvalidOperationException(discMountJob.OUT_Log); throw new InvalidOperationException("\r\n" + discMountJob.OUT_Log);
if (disc == null) if (disc == null)
throw new InvalidOperationException("Can't load one of the files specified in the M3U"); throw new InvalidOperationException("Can't load one of the files specified in the M3U");

View File

@ -365,6 +365,13 @@ namespace BizHawk.Emulation.DiscSystem.CUE
void OpenTrack(CUE_File.Command.TRACK trackCommand) void OpenTrack(CUE_File.Command.TRACK trackCommand)
{ {
//assert that a file is open
if(curr_file == null)
{
Error("Track command encountered with no active file");
throw new DiscJobAbortException();
}
curr_track = new CompiledCueTrack(); curr_track = new CompiledCueTrack();
//spill cdtext data into this track //spill cdtext data into this track

View File

@ -55,4 +55,8 @@ namespace BizHawk.Emulation.DiscSystem
swLog.Write(job.OUT_Log); swLog.Write(job.OUT_Log);
} }
} }
class DiscJobAbortException : Exception
{
};
} }

View File

@ -126,6 +126,8 @@ namespace BizHawk.Emulation.DiscSystem
} }
if (ext == ".cue") if (ext == ".cue")
{ {
//TODO - major renovation of error handling needed
//TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors. //TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors.
//perhaps the CUE_Format2 (once renamed to something like Context) can handle that //perhaps the CUE_Format2 (once renamed to something like Context) can handle that
var cuePath = IN_FromPath; var cuePath = IN_FromPath;
@ -140,21 +142,25 @@ namespace BizHawk.Emulation.DiscSystem
if (cue_content == null) if (cue_content == null)
cue_content = File.ReadAllText(cuePath); cue_content = File.ReadAllText(cuePath);
parseJob.IN_CueString = cue_content; parseJob.IN_CueString = cue_content;
parseJob.Run(parseJob); bool okParse = true;
//TODO - need better handling of log output try { parseJob.Run(parseJob); }
catch (DiscJobAbortException) { okParse = false; parseJob.FinishLog(); }
if (!string.IsNullOrEmpty(parseJob.OUT_Log)) Console.WriteLine(parseJob.OUT_Log); if (!string.IsNullOrEmpty(parseJob.OUT_Log)) Console.WriteLine(parseJob.OUT_Log);
ConcatenateJobLog(parseJob); ConcatenateJobLog(parseJob);
if (!okParse)
goto DONE;
//compile the cue file: //compile the cue file:
//includes this work: resolve required bin files and find out what it's gonna take to load the cue //includes this work: resolve required bin files and find out what it's gonna take to load the cue
var compileJob = new CompileCueJob(); var compileJob = new CompileCueJob();
compileJob.IN_CueContext = cueContext; compileJob.IN_CueContext = cueContext;
compileJob.IN_CueFile = parseJob.OUT_CueFile; compileJob.IN_CueFile = parseJob.OUT_CueFile;
compileJob.Run(); bool okCompile = true;
//TODO - need better handling of log output try { compileJob.Run(); }
catch (DiscJobAbortException) { okCompile = false; compileJob.FinishLog(); }
if (!string.IsNullOrEmpty(compileJob.OUT_Log)) Console.WriteLine(compileJob.OUT_Log); if (!string.IsNullOrEmpty(compileJob.OUT_Log)) Console.WriteLine(compileJob.OUT_Log);
ConcatenateJobLog(compileJob); ConcatenateJobLog(compileJob);
if (compileJob.OUT_ErrorLevel) if (!okCompile || compileJob.OUT_ErrorLevel)
goto DONE; goto DONE;
//check slow loading threshold //check slow loading threshold