You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Full disclosure: I'm not the best Java programmer. When I wrote the Java code for the Alda client, I included a couple of convenience functions for printing messages and errors that bubble up from the Alda servers. These functions are basically wrappers around printf, with some program-specific context like the port the server is running on.
Occasionally, things can get weird if the message or error strings happens to contain some unexpected formatting characters like %s. This may be what was happening here in the stacktrace @elyisgreat was getting.
I'm opening this up to all the Java programmers out there:
Is there a way these convenience functions can be made more robust so that they won't fail if the message string contains unexpected format characters?
Is the java.util.UnknownFormatConversionException: Conversion = '1' error indicative of some other problem?
The text was updated successfully, but these errors were encountered:
Sorry for not contributing in a long time, I've been kind of backed up on other projects, but I'll probably work a bit more on alda in about a month!
That error message is likely something wrong with the inputs into printf, either % directives that don't exist (like %q I think?), or perhaps there are an incorrect number of % directives. From the error, I'm guessing that there is a %1 in your input to printf.
In general, java programmers don't use printf, as the built in string addition is more robust and easier to use.
The possible solutions I can think of are:
(the easiest) Make sure inputs into the msg functions are valid printf statements, and make sure you have the correct number of arguments. Effectively, you would be treating msg as a printf function, as you do now. If you do this, it's up to callers of this function to make sure the input is valid. In this case, you would have to make sure the prefix variable does not contain any printf special characters.
Switch over to use string addition entirely, by passing in a list of args, and your function will string concatenate them and print them out.
(probably the cleanest) pass a pure string into msg and let the caller deal with concatenation and message formatting. The caller could make a sprintf (equivalent) call themselves.
If I have a bit of free time I'll look at the error thats in the attached issue.
Full disclosure: I'm not the best Java programmer. When I wrote the Java code for the Alda client, I included a couple of convenience functions for printing messages and errors that bubble up from the Alda servers. These functions are basically wrappers around
printf
, with some program-specific context like the port the server is running on.Occasionally, things can get weird if the message or error strings happens to contain some unexpected formatting characters like
%s
. This may be what was happening here in the stacktrace @elyisgreat was getting.I'm opening this up to all the Java programmers out there:
java.util.UnknownFormatConversionException: Conversion = '1'
error indicative of some other problem?The text was updated successfully, but these errors were encountered: