Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with an unhandled exception in small molecule transition list reader… #2741

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions pwiz_tools/Skyline/Model/SmallMoleculeTransitionListReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ private bool ErrorAddingToExistingMoleculeGroup(ref SrmDocument document, Parsed
return false;
}

// Check for the various kinds of exceptions that may be thrown in the course of
// parsing sometimes-wonky user data
private bool IsParserException(Exception exception)
{
return exception is InvalidOperationException
|| exception is InvalidDataException
|| exception is ArgumentException;
}

// Returns true on error
private bool ErrorFindingTransitionGroupForPrecursor(ref SrmDocument document, ParsedIonInfo precursor, Row row,
PeptideGroupDocNode pepGroup, Adduct adduct, double precursorMonoMz, double precursorAverageMz,
Expand Down Expand Up @@ -296,13 +305,9 @@ private bool ErrorFindingTransitionGroupForPrecursor(ref SrmDocument document, P
_firstAddedPathPepGroup = _firstAddedPathPepGroup ?? pathGroup;
}
}
catch (InvalidDataException x)
{
errmsg = x.Message;
}
catch (InvalidOperationException x) // Adduct handling code can throw these
catch (Exception exception) when (IsParserException(exception))
{
errmsg = x.Message;
errmsg = exception.Message;
}

if (errmsg != null)
Expand Down Expand Up @@ -1357,7 +1362,7 @@ private ParsedIonInfo ReadPrecursorOrProductColumns(SrmDocument document,
adduct = DetermineAdductFromFormulaChargeAndMz(formula, charge.Value, mz);
}
}
catch (Exception e)
catch (Exception e) when (IsParserException(e))
{
ShowTransitionError(new PasteError
{
Expand Down Expand Up @@ -1511,13 +1516,9 @@ private ParsedIonInfo ReadPrecursorOrProductColumns(SrmDocument document,
}
}
}
catch (InvalidDataException x)
catch (Exception exception) when (IsParserException(exception))
{
massErrMsg = x.Message;
}
catch (InvalidOperationException x) // Adduct handling code can throw these
{
massErrMsg = x.Message;
massErrMsg = exception.Message;
}
if (massErrMsg != null)
{
Expand Down Expand Up @@ -1704,7 +1705,7 @@ private bool ProcessAdduct(Row row, int indexAdduct, int indexFormula, bool getP
adduct = Adduct.FromStringAssumeChargeOnly(adductText);
IonInfo.ApplyAdductToFormula(formula ?? string.Empty, adduct); // Just to see if it throws
}
catch (Exception x) when ((x is InvalidOperationException) || (x is ArgumentException))
catch (Exception x) when (IsParserException(x))
{
ShowTransitionError(new PasteError
{
Expand Down Expand Up @@ -1831,7 +1832,7 @@ private PeptideDocNode GetMoleculePeptide(SrmDocument document, Row row, Peptide
molecule = new CustomMolecule(parsedIonInfo.MonoMass, parsedIonInfo.AverageMass, shortName, parsedIonInfo.MoleculeID.AccessionNumbers);
}
}
catch (ArgumentException e)
catch (Exception e) when (IsParserException(e))
{
ShowTransitionError(new PasteError
{
Expand All @@ -1849,7 +1850,7 @@ private PeptideDocNode GetMoleculePeptide(SrmDocument document, Row row, Peptide
return null;
return new PeptideDocNode(pep, document.Settings, null, null, parsedIonInfo.ExplicitRetentionTime, new[] { tranGroup }, false);
}
catch (InvalidOperationException e)
catch (Exception e) when (IsParserException(e))
{
ShowTransitionError(new PasteError
{
Expand Down Expand Up @@ -1908,11 +1909,7 @@ private TransitionGroupDocNode GetMoleculeTransitionGroup(SrmDocument document,
return new TransitionGroupDocNode(group, document.Annotations, document.Settings, null,
null, moleculeInfo.ExplicitTransitionGroupValues, null, new[] { tran }, false);
}
catch (InvalidDataException x)
{
errmsg = x.Message;
}
catch (InvalidOperationException x) // Adduct handling code can throw these
catch (Exception x) when (IsParserException(x))
{
errmsg = x.Message;
}
Expand Down