RaiMan / SikuliX1

SikuliX version 2.0.0+ (2019+)
https://sikulix.github.io
MIT License
2.77k stars 355 forks source link

FormatFlagsConversionMismatchException when reporting error #258

Closed DavidPerezIngeniero closed 4 years ago

DavidPerezIngeniero commented 4 years ago

After trying Sikulix 2.0.1 I see this error:

java.util.FormatFlagsConversionMismatchException: Conversion = s, Flags =  
    at java.util.Formatter$FormatSpecifier.failMismatch(Formatter.java:4298)
    at java.util.Formatter$FormatSpecifier.checkBadFlags(Formatter.java:2997)
    at java.util.Formatter$FormatSpecifier.checkGeneral(Formatter.java:2955)
    at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2725)
    at java.util.Formatter.parse(Formatter.java:2560)
    at java.util.Formatter.format(Formatter.java:2501)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at org.sikuli.basics.Debug.doRedirect(Debug.java:590)
    at org.sikuli.basics.Debug.error(Debug.java:680)
    at org.sikuli.script.runnerSupport.JythonSupport.findErrorSource(JythonSupport.java:896)
    at org.sikuli.script.runners.JythonRunner.doRunScript(JythonRunner.java:179)
    at org.sikuli.script.runners.AbstractScriptRunner.lambda$runScript$0(AbstractScriptRunner.java:173)
    at org.sikuli.script.runners.AbstractScriptRunner$1.run(AbstractScriptRunner.java:316)

Running with Java 1.8.0.222, Linux 64 bits

RaiMan commented 4 years ago

please confirm:

  1. you are using the logging callback feature
  2. the script ran without errors in 1.1.4 or earlier

apparently the script runs into an error and the problem is with the error reporting.

if 1. is true: switch off the logging callback and run the script from commandline: java -jar /sikulix.jar -v -c -r yourscript.sikuli

... hopefully this shows more details about the possible problem

DavidPerezIngeniero commented 4 years ago

You've guessed, I capture all logging output, by using Debug.setLoggerNoPrefix(). It used to work with SikuliX 1.1.4 SNAPSHOT. Thanks RaiMan.

I've disabled custom logging and here is now the ouput:

[error] java.lang.NoSuchMethodError ( java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector; )
Exception in thread "Thread-14" java.util.FormatFlagsConversionMismatchException: Conversion = s, Flags =  
    at java.util.Formatter$FormatSpecifier.failMismatch(Formatter.java:4298)
    at java.util.Formatter$FormatSpecifier.checkBadFlags(Formatter.java:2997)
    at java.util.Formatter$FormatSpecifier.checkGeneral(Formatter.java:2955)[ABM_puntoMapa       ] 
    at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2725)
    at java.util.Formatter.parse(Formatter.java:2560)
    at java.util.Formatter.format(Formatter.java:2501)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2940)
    at org.sikuli.basics.Debug.log(Debug.java:848)
    at org.sikuli.basics.Debug.error(Debug.java:683)
    at org.sikuli.script.runnerSupport.JythonSupport.findErrorSource(JythonSupport.java:896)
    at org.sikuli.script.runners.JythonRunner.doRunScript(JythonRunner.java:179)
    at org.sikuli.script.runners.AbstractScriptRunner.lambda$runScript$0(AbstractScriptRunner.java:173)
    at org.sikuli.script.runners.AbstractScriptRunner$1.run(AbstractScriptRunner.java:3
Debug.error("--- Traceback --- error source first\n" + "line: module ( function ) statement \n" + errorTrace
                  + "[error] --- Traceback --- end --------------")

Maybe errorTrace contains some "%" character.

balmma commented 4 years ago

Maybe errorTrace contains some "%" character.

Might very well be. The log functions take a format string and allow to pass an argument list for string interpolation. What you can do is to escape the % using %%.

@RaiMan It would probably be worth not to use the String.format() method in case of null or empty args. When no args are given one obviously do not want to do the string interpolation and might rather just log an arbitrary String (which might contain %). Would be more robust IMHO.

balmma commented 4 years ago

Should be fixed with PR #263 .

DavidPerezIngeniero commented 4 years ago

I think this is a good idea.

RaiMan commented 4 years ago

Yes, me too ;-)