Skip to content

convert Runtime exceptions in the CRAM code into CRAMExceptions (also… #1526

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yfarjoun
Copy link
Contributor

… runtime)

(sorry again about the push to master)

Description

Please explain the changes you made here.
Explain the motivation for making this change. What existing problem does the pull request solve?

Things to think about before submitting:

  • Make sure your changes compile and new tests pass locally.
  • Add new tests or update existing ones:
    • A bug fix should include a test that previously would have failed and passes now.
    • New features should come with new tests that exercise and validate the new functionality.
  • Extended the README / documentation, if necessary
  • Check your code style.
  • Write a clear commit title and message
    • The commit message should describe what changed and is targeted at htsjdk developers
    • Breaking changes should be mentioned in the commit message.

@yfarjoun yfarjoun requested a review from cmnbroad December 23, 2020 20:53
Copy link
Collaborator

@cmnbroad cmnbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yfarjoun Most of these seem good; except for a couple. If you don't have time to finish this just let me know and I'll take it over.

@@ -73,7 +74,7 @@ public CRAMReferenceRegion(final CRAMReferenceSource cramReferenceSource, final
final SAMSequenceRecord sequence = samFileHeader.getSequence(referenceIndex);
referenceBases = referenceSource.getReferenceBases(sequence, true);
if (referenceBases == null) {
throw new IllegalArgumentException(
throw new CRAMException(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the original intent of CRAMException was, but starting with the CRAM rewrite I restricted it's use to internal error conditions, such as malformed input as reported in broadinstitute/picard#1624. Not all of the CRAM codebase is conforming yet, but I don't think this is a case where CRAMException makes sense, since this is a user error.

@@ -422,7 +423,7 @@ private EncodingDetails buildEncodingForTag(final List<CRAMCompressionRecord> re
new ExternalByteArrayEncoding(tagID)).toEncodingDescriptor();
return details;
default:
throw new IllegalArgumentException("Unknown tag type: " + (char) type);
throw new CRAMException("Unknown tag type: " + (char) type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one does seem like an appropriate case for CRAMException.

@@ -88,7 +90,7 @@ public static long writeCramEOF(final CRAMVersion cramVersion, final OutputStrea
throw new RuntimeIOException(e);
}

throw new IllegalArgumentException(String.format("Unrecognized CRAM version %s", cramVersion));
throw new CRAMException(String.format("Unrecognized CRAM version %s", cramVersion));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is borderline, but I'd err on leaving it as IllegalArgumentException, or else RuntimeException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants