Thread Locked This thread is locked - replies are not allowed.


This question is answered.


Permlink Replies: 12 - Pages: 1 - Last Post: 25 May 23, 19:24 Last Post By: davidekholm Threads: [ Previous | Next ]
AndreWolff

Posts: 2,151
Registered: 14-Dec-2007
Groovy problem
Posted: 25 May 23, 17:37
 
Groovy is driving me crazy!

I use already a long time the same piece of code for my FancyBox skin en for the PhotoSwipe skin for the same set of images and settings.
It works OK with fancyBox, but now suddenly it crashes with PhotoSwipe:
Stack trace for jAlbum 31.0.1 using skin PhotoSwipe 5.4.3:
 
se.datadosen.util.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script143.groovy: 24: Unexpected input: '{\r\n if (showExposureDateThumb||showFilenames||showTitle||showDescriptions) {\r\n System.out.println("2 textToShow: "  +  textToShow);\r\n   out.print("<div class="\"thumbText\"">");   \r\n   if (showFilenames) {\r\n     out.print("<small>");    \r\n     out.print(label.replaceAll("_"," "));\r\n \tout.print("</small><br>"); \r\n   }\r\n\r\n   if (showTitle &&  fileTitle.length() > 0) {\r\n     out.print("<strong>");        \r\n     out.print(fileTitle);\r\n     out.print("</strong><br>"); \r\n   }\r\n   \r\n   if (showDescriptions) {\r\n     out.print(shortComment);    \r\n   }\r\nif (exists.originalDate) {\r\n  if (showExposureDateThumb) )' in index.htt at line number 634 at column number 30
	at se.datadosen.util.ScriptException.of(ScriptException.java:59)

This is the piece of code:
<%
boolean textToShow= (showExposureDateThumb||showFilenames || (showTitle &&  (fileTitle.length() > 0)) ||  (showDescriptions &&  (shortComment.length() > 0))); 
System.out.println("1 textToShow: "  +  textToShow);
if (!masonryGallery || (masonryGallery && textToShow)) {
 if (showExposureDateThumb||showFilenames||showTitle||showDescriptions) {
 System.out.println("2 textToShow: "  +  textToShow);
   out.print("<div class="\"thumbText\"">");   
   if (showFilenames) {
     out.print("<small>");    
     out.print(label.replaceAll("_"," "));
 	out.print("</small><br>"); 
   }
 
   if (showTitle &&  fileTitle.length() > 0) {
     out.print("<strong>");        
     out.print(fileTitle);
     out.print("</strong><br>"); 
   }
   
   if (showDescriptions) {
     out.print(shortComment);    
   }
if (exists.originalDate) {
  if (showExposureDateThumb) ) {
     if (showDescriptions && shortComment.length()>0) {
          out.print("<br>");  
     } 
     out.print(originalDate); 
  }
 }
   
   out.print("</div>");
 }
 
 }
%>


Can anybody explain this difference in behavior?

I spent already a day on this problem, but I can't solve the problem.

Replacing
boolean textToShow=
by
textToShow=
does not help.

There is no crash if I remove this piece of code completely
JeffTucker

Posts: 8,084
Registered: 31-Jan-2006
Re: Groovy problem
Posted: 25 May 23, 17:51   in response to: AndreWolff in response to: AndreWolff
Correct
if (exists.originalDate) {
  if (showExposureDateThumb) ) {
     if (showDescriptions && shortComment.length()>0) {
          out.print("<br>");  
     } 
     out.print(originalDate); 
  }
 }
Count the opening and closing parentheses. ;)
RobM

Posts: 4,152
Registered: 4-Aug-2006
Re: Groovy problem
Posted: 25 May 23, 18:04   in response to: JeffTucker in response to: JeffTucker
 
JeffTucker wrote:
if (exists.originalDate) {
  if (showExposureDateThumb) ) {
     if (showDescriptions && shortComment.length()>0) {
          out.print("<br>");  
     } 
     out.print(originalDate); 
  }
 }
Count the opening and closing parentheses. ;)
Whenever I see
Unexpected input: 
I look at the last change I made and then search for a typo error, unmatched braces (mostly cured by code auto complete), an apostrophe where it should not be (copy/paste induced error). It is always down to human error.
Alas, I’m getting familiar with it. ;)
AndreWolff

Posts: 2,151
Registered: 14-Dec-2007
Re: Groovy problem
Posted: 25 May 23, 18:07   in response to: JeffTucker in response to: JeffTucker
 
Jeff you are a Genius!

Thanks a lot!
AndreWolff

Posts: 2,151
Registered: 14-Dec-2007
Re: Groovy problem
Posted: 25 May 23, 18:10   in response to: RobM in response to: RobM
 
RobM wrote:
Whenever I see
Unexpected input: 
I look at the last change I made and then search for a typo error, unmatched braces (mostly cured by code auto complete), an apostrophe where it should not be (copy/paste induced error). It is always down to human error.
Alas, I’m getting familiar with it. ;)
Why is GROOVY that not doing and giving next an understandable error message?
RobM

Posts: 4,152
Registered: 4-Aug-2006
Re: Groovy problem
Posted: 25 May 23, 18:23   in response to: AndreWolff in response to: AndreWolff
 
You might not like it, but that message is entirely understandable.
AndreWolff

Posts: 2,151
Registered: 14-Dec-2007
Re: Groovy problem
Posted: 25 May 23, 18:47   in response to: RobM in response to: RobM
 
RobM wrote:
You might not like it, but that message is entirely understandable.
You're joking!

An understandable message would be:

Unexpected character ')' at line 960

The BeanShell messages were already bad, but the GROOVY messages are worthless.

Another Groovy shortcoming:

GROOVY only tests the loops / branches used in the current album.

Until today my skin did contain this old BEANSHELL code:
if (showExposureDateThumb && (originalDate != void) ) {
   if (showDescriptions && shortComment.length()>0) {
          out.print("<br>");  
   } 
   out.print(originalDate); 
 }

Although the GROOVY version is already 8 months old, nobody including myself encountered this problem!

I'm glad I don't have to make a living with such crippled programming language!
JeffTucker

Posts: 8,084
Registered: 31-Jan-2006
Re: Groovy problem
Posted: 25 May 23, 18:47   in response to: AndreWolff in response to: AndreWolff
 
AndreWolff wrote:
Why is GROOVY that not doing and giving next an understandable error message?

This is what the error message said:
...in index.htt at line number 634 at column number 30
It gave you the name of the file where the error occurred, the line number on which it occurred, and even which character caused the error. What more could it do?
AndreWolff

Posts: 2,151
Registered: 14-Dec-2007
Re: Groovy problem
Posted: 25 May 23, 18:53   in response to: JeffTucker in response to: JeffTucker
 
JeffTucker wrote:
This is what the error message said:code...in index.htt at line number 634
That is not the correct line number!
... and even which character caused the error. What more could it do?
?? where can I see which character caused the error?
JeffTucker

Posts: 8,084
Registered: 31-Jan-2006
Re: Groovy problem
Posted: 25 May 23, 19:05   in response to: AndreWolff in response to: AndreWolff
 
Attachment line.png (35.7 KB)
Attachment character.png (8.0 KB)
AndreWolff wrote:
JeffTucker wrote:
This is what the error message said:code...in index.htt at line number 634
That is not the correct line number!

That's the line number in the version of Photoswipe I've got - see line.png.

But the parsers in software often don't count comment lines, so they're sometimes a few lines off.

?? where can I see which character caused the error?

It's the 30th character on the line, just like it said. And it shows you where it ran into trouble - see character.png.
AndreWolff

Posts: 2,151
Registered: 14-Dec-2007
Re: Groovy problem
Posted: 25 May 23, 19:09   in response to: JeffTucker in response to: JeffTucker
 
Well chatGPT gives immediately the correct and understandable message:

The error in the given GROOVY code is a syntax error in the following line:

```groovy
if (showExposureDateThumb) ) {
```

There is an extra closing parenthesis `)` before the opening brace `{`. The correct line should be:

```groovy
if (showExposureDateThumb) {


GROOVY shouyld learn from that!```

JeffTucker

Posts: 8,084
Registered: 31-Jan-2006
Re: Groovy problem
Posted: 25 May 23, 19:12   in response to: AndreWolff in response to: AndreWolff
 
Maybe you should get AI to write your code.

Question answered. We are not going to start on one of your "arguing for the sake of arguing" rants. It's just too tiresome.
davidekholm

Posts: 4,121
Registered: 18-Oct-2002
Re: Groovy problem
Posted: 25 May 23, 19:24   in response to: JeffTucker in response to: JeffTucker
 
André. I agree that Groovy's line number reporting is sometimes bad. Please bear in mind that we're a small company, so if you wish this to be improved, report the problem directly to the Groovy developers.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums