My point is: Noone should catch such a non-recoverable development exception. Otherwise the underlying bug might slip through. So logging is IMHO not sufficient. The exception should bubble up and lead to a 500 status!
> On 15. Apr 2020, at 17:54, Radu Cotescu <r...@apache.org> wrote: > > Hi Konrad, > > I know about that subtle difference, but couldn’t we log the failure of > instantiating the model in the adapter factories? It’s anyways not something > we can recover from. In case of a failure of the SlingModelsUseProvider > instantiating the model we wrap the original exception in a > org.apache.sling.scripting.sightly.SightlyException (RuntimeException) and > throw. > > Thanks, > Radu > >> On 15 Apr 2020, at 17:07, Konrad Windszus <konra...@gmx.de> wrote: >> >> There is one important difference: The Java Use Provider uses >> adaptTo(...)(https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/a0f0e77a30ecf3091cfa69d21ff46e0994e4e19f/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java#L160 >> >> <https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/a0f0e77a30ecf3091cfa69d21ff46e0994e4e19f/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java#L160> >> >> <https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/a0f0e77a30ecf3091cfa69d21ff46e0994e4e19f/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java#L160 >> >> <https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/a0f0e77a30ecf3091cfa69d21ff46e0994e4e19f/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java#L160>>) >> while the Models Use Provider uses ModelsFactory.createModel(...) >> (https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/6ef6d531fc15d23744a6a60f798e36c2d368c3ab/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java#L126 >> >> <https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/6ef6d531fc15d23744a6a60f798e36c2d368c3ab/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java#L126> >> >> <https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/6ef6d531fc15d23744a6a60f798e36c2d368c3ab/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java#L126 >> >> <https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/6ef6d531fc15d23744a6a60f798e36c2d368c3ab/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java#L126>>). >> The latter does not not catch any exceptions, so debugging issues is a lot >> easier than relying on adaptTo which only emits some log with level WARN (or >> even below) in case model instantiation fails (compare with [1] and [2]). >> >> Konrad >> >> [1] - >> https://sling.apache.org/documentation/bundles/models.html#modelfactory-since-120 >> >> <https://sling.apache.org/documentation/bundles/models.html#modelfactory-since-120><https://sling.apache.org/documentation/bundles/models.html#modelfactory-since-120 >> >> <https://sling.apache.org/documentation/bundles/models.html#modelfactory-since-120>> >> [2] - https://issues.apache.org/jira/browse/SLING-3709 >> <https://issues.apache.org/jira/browse/SLING-3709> >> <https://issues.apache.org/jira/browse/SLING-3709 >> <https://issues.apache.org/jira/browse/SLING-3709>> >