Skip to content

SingleValue converter exceptions need "name" in the exception. #3465

@agentgt

Description

@agentgt

When a SingleValue does its conversion it is painful to figure out which parameter actually caused the exception even though SingleValue has the name.

java.lang.IllegalArgumentException: UUID string too large
	at java.base/java.util.UUID.fromString1(UUID.java:266)
	at java.base/java.util.UUID.fromString(UUID.java:260)
	at io.jooby.internal.converter.UUIDConverter.convert(UUIDConverter.java:21)
	at io.jooby.internal.ValueConverters.convert(ValueConverters.java:119)
	at io.jooby.internal.ValueConverters.convert(ValueConverters.java:71)
	at io.jooby.DefaultContext.convertOrNull(DefaultContext.java:410)
	at io.jooby.internal.SingleValue.toNullable(SingleValue.java:95)
	at SomeController_.get(SomeController_.java:37)

In SingleValue we have:

  @NonNull @Override
  public <T> T to(@NonNull Class<T> type) {
    return ctx.convert(this, type);
  }

  @Nullable @Override
  public <T> T toNullable(@NonNull Class<T> type) {
    return ctx.convertOrNull(this, type);
  }

In theory we do not need to change API at all but have the builtin converters check if the passed in this has a Value.name() and wrap the exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions