Skip to content

IllegalArgumentException while creating EidRuntimeException with valid message  #21

Description

@Fizol

Hi here is code example:

def "Unexpected behaviour"() {
        expect:
        throw new EidRuntimeException("json-processing", "This json={\"key} is wrong", null);
}

It throws:

java.lang.IllegalArgumentException: can't parse argument number: "key

	at java.text.MessageFormat.makeFormat(MessageFormat.java:1429)
	at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
	at java.text.MessageFormat.<init>(MessageFormat.java:362)
	at pl.wavesoftware.eid.impl.MessageSupplier.getFormatter(MessageSupplier.java:59)
	at pl.wavesoftware.eid.impl.MessageSupplier.get(MessageSupplier.java:51)
	at pl.wavesoftware.eid.impl.MessageSupplier.get(MessageSupplier.java:32)
	at pl.wavesoftware.eid.impl.Lazy.get(Lazy.java:57)
	at pl.wavesoftware.eid.impl.SerializableLazy.get(SerializableLazy.java:50)
	at pl.wavesoftware.eid.impl.TextMessage.get(TextMessage.java:43)
	at pl.wavesoftware.eid.impl.EidTextRepresentation$1.get(EidTextRepresentation.java:48)
	at pl.wavesoftware.eid.impl.EidTextRepresentation$1.get(EidTextRepresentation.java:44)
	at pl.wavesoftware.eid.impl.Lazy.get(Lazy.java:57)
	at pl.wavesoftware.eid.impl.SerializableLazy.get(SerializableLazy.java:50)
	at pl.wavesoftware.eid.impl.EidTextRepresentation.get(EidTextRepresentation.java:63)
	at pl.wavesoftware.eid.impl.DefaultEidMessage.toString(DefaultEidMessage.java:69)
	at pl.wavesoftware.eid.exceptions.EidRuntimeException.<init>(EidRuntimeException.java:240)
	at pl.wavesoftware.eid.exceptions.EidRuntimeException.<init>(EidRuntimeException.java:131)
	at com.roche.gyst.structure_importer.structure_preparation.atomic_sequence.DockerScriptOutputConverterTest.Unexpected behaviour(DockerScriptOutputConverterTest.groovy:14)
Caused by: java.lang.NumberFormatException: For input string: ""key"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:569)
	at java.lang.Integer.parseInt(Integer.java:615)
	at java.text.MessageFormat.makeFormat(MessageFormat.java:1427)
	... 17 more

for

<version>2.0.0</version>

It's unexpected because constructor's documentation doesn't describe that message will be use as format input. I consider this as a problem.
Then I don't know how I can extend your API. I want to hide your classes behind my exception class. Eg.

class XXXRuntimeException extends EidRuntimeException {
    public XXXRuntimeException(CharSequence eid, String message, @Nullable Throwable cause) {
        super(eid, message, cause);
    }
}

It hides your types, but I can't use your constructor because it treats "message" as input for format.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions