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

Ben Weidig commented on TAP5-2738:
----------------------------------

I finally got some time to check this out, and as usual, it's more complicated 
than a simple change...

The Exception reaching the user is initially thrown in 
org.apache.tapestry5.services.BindingSource.newBinding(String, 
ComponentResources, String, String), where the first parameter is a description 
of the Binding.

The description is only available in the Binding itself.
In the case of an error, like an invalid property expression, the description 
is lost as it's not used for the Exception.

Adding the description to the Exception message might be simple, but it has 
certain implications.
Just adding it means updating the description where it's provided to something 
more meaningful.

As the newBinding method is only used in a few places,
 * org.apache.tapestry5.internal.services.ComponentDefaultProviderImpl
 * org.apache.tapestry5.internal.transform.CachedWorker
 * org.apache.tapestry5.internal.transform.ParameterWorker
 * org.apache.tapestry5.internal.dynamic.DynamicTemplateSaxParser
 * org.apache.tapestry5.internal.services.PageElementFactoryImpl

it shouldn't be an issue, though.

However, this means inevitable repetition, for example:

Could not convert 'unknown' (@Cached watch(value='unknown')) into a component 
parameter binding: Exception generating conduit for expression 'unknown': Class 
org.apache.tapestry5.integration.app1.pages.UnknownWatchValueWithCached does 
not contain a property (or public field) named 'unknown'.

A more readable solution would be adding another parameter to the newBinding 
method equivalent to Location, but instead of providing more context about the 
resource, it should contain context for the related Worker/Service.

> @Cached should throw a more sensible exception if field is mising
> -----------------------------------------------------------------
>
>                 Key: TAP5-2738
>                 URL: https://issues.apache.org/jira/browse/TAP5-2738
>             Project: Tapestry 5
>          Issue Type: Improvement
>          Components: tapestry-core
>    Affects Versions: 5.8.1
>            Reporter: Ben Weidig
>            Assignee: Ben Weidig
>            Priority: Minor
>
> The value of the annotation is String-based and therefore error-prone, 
> especially during refactoring, etc.
> Currently, the thrown exception is only saying that a field is missing, and 
> the CachedWorker is only visible in the Stacktrace.
> I suggest the worker should catch the exception/missing binding, and rethrow 
> with a better message.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to