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

ASF GitHub Bot commented on GROOVY-10958:
-----------------------------------------

paulk-asert merged PR #1871:
URL: https://github.com/apache/groovy/pull/1871




> Confusing error message from GroovyScriptEngine
> -----------------------------------------------
>
>                 Key: GROOVY-10958
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10958
>             Project: Groovy
>          Issue Type: Improvement
>          Components: GroovyScriptEngine
>    Affects Versions: 2.5.19, 3.0.15, 4.0.9
>            Reporter: Charlie Hubbard
>            Priority: Minor
>
> When the GroovyScriptEngine can't find a file or receives a Malformed URL it 
> writes out a message like this:
> {code:java}
> groovy.util.ResourceException: Cannot open URL: 
> file:/var/lib/jenkins/workspace/TheProject/web/src/main/webapp/WEB-INF/scripts/,
>  DocumentETL.groovy
>  {code}
> The confusing part is the ", " inserted between the path and the filename.  
> The way it reads looks like there is an errant ", " in the full path sent to 
> the URL.    No wonder it can't find it.  But, it turns out the exception 
> processing logic is inserting that.   Here is the exert from the code:
> {code:java}
> } catch (MalformedURLException e) {
>     String message = "Malformed URL: " + root + ", " + resourceName;
>     if (se == null) {
>         se = new ResourceException(message);
>     } else {
>         se = new ResourceException(message, se);
>     }
> } catch (IOException e1) {
>     String message = "Cannot open URL: " + root + ", " + resourceName;
>     groovyScriptConn = null;
>     if (se == null) {
>         se = new ResourceException(message);
>     } else {
>         se = new ResourceException(message, se);
>     }
> }{code}
> This will cause people to go searching for some errant command-space 
> throughout their code while debugging issues like this because we are 
> normally conditioned to see the full path that the system is attempting to 
> load.  The phrase before insinuates the full URL is next.  As opposed to a 
> segmented version of it.  The will cause people to overlook what is really 
> the error because it's such an aberrant message.
> Using the `scriptUrl` in the message would make more sense when IOException 
> was thrown: 
> {code:java}
> String message = "Cannot open URL: " + scriptUrl;
> {code}
> For the malformed exception it might be tricky to reconstruct the full URL, 
> but it should be made more clear like:
> {code:java}
> String message = "Malformed URL: with context=" + root + " and spec=" + 
> resourceName + " because " + e.getMessage();{code}
> Some way to delimit the parts of the URL if you can't create the full context.



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

Reply via email to