#I really really really wish for a better exception message for createToken

1 messages ยท Page 1 of 1 (latest)

slender oyster
#

I am working on an add-on where I create a number of maps with a few tokens on during onFirstInit. This is working fine, except for one token.
I get this error:

00:28:06.190 DEBUG net.rptools.maptool.client.MapToolLineParser - screenTexture = "lib://" + ns + "/assets/images/bgtexture.png"
00:28:06.190 DEBUG net.rptools.maptool.client.MapToolLineParser - tokenId = createToken(
    json.set("{}",
        "name","Image:Texture",
        "tokenImage", screenTexture,
        "size","Native",
        "layer", "Hidden"
    )
)
00:28:06.192 DEBUG net.rptools.maptool.client.MapToolLineParser - net.rptools.parser.ParserException: Argument number 1 invalid argument type for function "copyToken".
00:28:06.192 ERROR net.rptools.maptool.client.swing.MapToolEventQueue - java.util.concurrent.CompletionException: net.rptools.parser.ParserException: Argument number 1 invalid argument type for function "copyToken".
java.util.concurrent.CompletionException: net.rptools.parser.ParserException: Argument number 1 invalid argument type for function "copyToken".

I have copied the code from another token which is created fine, and just edited a couple of values and then I get this.
The code for creating the token looks like this:

[h:screenTexture = "lib://" + ns + "/assets/images/bgtexture.png"]
[h:tokenId = createToken(
    json.set("{}",
        "name","Image:Texture",
        "tokenImage", screenTexture,
        "size","Native",
        "layer", "Hidden"
    )
)]

The exact same syntax is used several times successfully with other tokens, only different is the values of the json.

Any ideas on what I am missing here?

And would anyone with half an idea what they're doing (i.e. anyone but me) please improve the error message from createToken?! ๐Ÿ˜„

slender oyster
#

For f** sake... It was the actually file name. All other token images are png, but this particular one is jpeg ... I am going to bed ...
My wish for a better error message still stands though ๐Ÿ˜‰

austere girder
#
  1. Looks like someone's copy-pasta retained the copyToken label, or if it is built into an extension of the copyToken code it is not changing the function name.

Having a look at size options on different layers. Hidden doesn't have native size it has free size. I wonder if this is actually different or if it is synonymous.
I wonder if the : in the name is the issue. It would not surprise me if Image: type token labels were missed in the implementation.
Wondering also if the image address causes it to fail.

reef stratus
#

Each of those should have their own error messages, of course. It's likely the original code just has a single error message to cover an entire range of problems. ๐Ÿ˜ฆ