> If I throw an excpetion which is created in a function I get an
> java.lang.VerifyError "Can only throw Trowable Objects" however if I
> create the exception directly everything works fine:
>
> module org.yeb.validation;
>
> validationException key msg lst value is string -> string ->
> list<string> -> 'a -> ~ValidationException=(
> msgO = message key msg lst;
> new ValidationException(msgO, value unsafely_as ~Object); // extends IllegalArgumentException
> );
>
> strToNum str =
> try
> number str
> catch java.lang.Exception ex:
> throw validationException "nonum" "%1$s is no number" [str] strB; //gives VerifyError
That's weird. It should give compilation error? It gives to me.
wtf.yeti:11:8: Not a Throwable instance (string -> string -> list<string> -> 'a -> ~wtf$ValidationException)
But after adding the parenthesis I got the VerifyError.
throw (validationException "nonum" "%1$s is no number" [str] strB);
> //this works fine: throw new ValidationException(message
> "nonum" "%1$s is nonumber" [str], str);
> yrt;
>
> The exception is.
>
> Exception in thread "Timer-0" java.lang.VerifyError: (class:org/yeb/
> validation$strFormatedToNum, method: _0 signature: (Lyeti/lang/
> Fun;Ljava/lang/String;Lyeti/
> lang/Tag;Lyeti/lang/Fun;)Ljava/lang/Object;) Can only throw Throwable
> objects
Looking the generated code I know why, missing checkcast. Should be fixed now.
> BTW: are java varargs supported or what is the best way to give an
> array of arbitrary content ~Object[] to ~java.lang.String#format()
> mixing numbers strings and all in an array list types?
list<~Object> is probably good for giving varargs (should be- Yeti is
unaware that varargs are special and sees what they are at the JVM level -
arrays).
> (~) x = x as ~Object
~ is 'a -> ~java.lang.Object = <code$$_>
> String#format("%2$s or %1$s", [2~, "kala"~])
"kala or 2" is string