Better error message when generic types are erased from scala collections.
This commit is contained in:
parent
008df54575
commit
fd59e7d5f6
|
|
@ -352,6 +352,9 @@ public class UserException extends ReviewedStingException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CannotExecuteQScript extends UserException {
|
public static class CannotExecuteQScript extends UserException {
|
||||||
|
public CannotExecuteQScript(String message) {
|
||||||
|
super(String.format("Unable to execute QScript: " + message));
|
||||||
|
}
|
||||||
public CannotExecuteQScript(String message, Exception e) {
|
public CannotExecuteQScript(String message, Exception e) {
|
||||||
super(String.format("Unable to execute QScript: " + message), e);
|
super(String.format("Unable to execute QScript: " + message), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import collection.JavaConversions._
|
||||||
import org.broadinstitute.sting.queue.QException
|
import org.broadinstitute.sting.queue.QException
|
||||||
import java.lang.Class
|
import java.lang.Class
|
||||||
import org.broadinstitute.sting.commandline.{ArgumentMatches, ArgumentSource, ArgumentTypeDescriptor, ParsingEngine}
|
import org.broadinstitute.sting.commandline.{ArgumentMatches, ArgumentSource, ArgumentTypeDescriptor, ParsingEngine}
|
||||||
|
import org.broadinstitute.sting.utils.exceptions.UserException
|
||||||
import java.lang.reflect.Type
|
import java.lang.reflect.Type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,6 +76,8 @@ class ScalaCompoundArgumentTypeDescriptor extends ArgumentTypeDescriptor {
|
||||||
|
|
||||||
def parse(parsingEngine: ParsingEngine, source: ArgumentSource, classType: Class[_], argumentMatches: ArgumentMatches) = {
|
def parse(parsingEngine: ParsingEngine, source: ArgumentSource, classType: Class[_], argumentMatches: ArgumentMatches) = {
|
||||||
val componentType = ReflectionUtils.getCollectionType(source.field)
|
val componentType = ReflectionUtils.getCollectionType(source.field)
|
||||||
|
if (componentType == classOf[java.lang.Object])
|
||||||
|
throw new UserException.CannotExecuteQScript("Please also include a @ClassType(classOf[<primitive type>]) annotation on field: " + source.field + ". Example: @ClassType(classOf[Double]). The scala generic type for the field was subjected to java/scala type erasure and is not available via reflection.")
|
||||||
val componentArgumentParser = parsingEngine.selectBestTypeDescriptor(componentType)
|
val componentArgumentParser = parsingEngine.selectBestTypeDescriptor(componentType)
|
||||||
|
|
||||||
if (classOf[Seq[_]].isAssignableFrom(classType)) {
|
if (classOf[Seq[_]].isAssignableFrom(classType)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue