You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@reef.apache.org by "Julia (JIRA)" <ji...@apache.org> on 2016/03/29 19:35:25 UTC

[jira] [Comment Edited] (REEF-1276) Improve error message shown when injectable class has [Parameter] annotation

    [ https://issues.apache.org/jira/browse/REEF-1276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15216414#comment-15216414 ] 

Julia edited comment on REEF-1276 at 3/29/16 5:34 PM:
------------------------------------------------------

Yes, you can replace the line as below:
                            var pn = RegisterType(constructorArg.GetNamedParameterName());
                            if (!(pn is INamedParameterNode))
                            {
                                Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(new ArgumentException(string.Format(CultureInfo.CurrentCulture, "The class {0} should be not defined as a NamedParameter.", constructorArg.GetNamedParameterName())), LOGGER);
                            }

                            INamedParameterNode np = (INamedParameterNode) pn;


was (Author: juliaw):
Yes, you can replace the line as below:

> Improve error message shown when injectable class has [Parameter] annotation
> ----------------------------------------------------------------------------
>
>                 Key: REEF-1276
>                 URL: https://issues.apache.org/jira/browse/REEF-1276
>             Project: REEF
>          Issue Type: Improvement
>          Components: Tang.NET
>            Reporter: Mariia Mykhailova
>            Assignee: Sergey Dudoladov
>            Priority: Minor
>
> {noformat}
>         [Inject]
>         private PoisonedEventHandler(
>             [Parameter(typeof(CrashProbability))] double crashProbability,
>             [Parameter(typeof(CrashTimeout))] int crashTimeout,
>             [Parameter(typeof(RuntimeClock))] RuntimeClock clock) 
>         {
>             ...
>         }
> {noformat}
> This code produces runtime error because {{RuntimeClock}} is not a primitive type and thus doesn't need an annotation. The error message is
> {noformat}
> ERROR: Exception in Call_clrSystemAllocatedEvaluatorHandler_OnNext:encountered error [System.InvalidCastException: Unable to cast object of type 'Org.Apache.REEF.Tang.Implementations.ClassHierarchy.ClassNodeImpl' to type 'Org.Apache.REEF.Tang.Types.INamedParameterNode'.
>    at Org.Apache.REEF.Tang.Implementations.ClassHierarchy.ClassHierarchyImpl.RegisterType(Type type)
>    at Org.Apache.REEF.Tang.Implementations.ClassHierarchy.ClassHierarchyImpl.GetNode(Type type)
>    at Org.Apache.REEF.Tang.Implementations.Configuration.CsConfigurationBuilderImpl.GetNode(Type c)
>    at Org.Apache.REEF.Tang.Implementations.Configuration.CsConfigurationBuilderImpl.Org.Apache.REEF.Tang.Interface.ICsInternalConfigurationBuilder.BindSetEntry(Type iface, Type impl)
>    at Org.Apache.REEF.Tang.Formats.ConfigurationModule.Build()
>    at Org.Apache.REEF.Tests.Functional.FaultTolerant.PoisonTest.PoisonedEvaluatorDriver.OnNext(IAllocatedEvaluator value)
> {noformat}
> It would be very nice to have something easier understandable, for example "Cannot interpret RuntimeClock as named parameter". Currently it takes a long time to figure out what exactly is wrong.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)