Skip to content

Clarify the use of exception in the conversion API [SPR-11500] #16125

@spring-projects-issues

Description

@spring-projects-issues

Benjamin M opened SPR-11500 and commented

The Converters documentation ( http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html ) says:

"Your Converter may throw any Exception if conversion fails. An IllegalArgumentException should be thrown to report an invalid source value."

BUT: I cannot use ANY Exception, the Exception to use must be a RuntimeException.

This doesn't work:

public class MyConverter implements Converter<A, B> {
@Override
public B convert(A a) {
throw new Exception();
}
}

Eclipse says: "Unhandled exception type Exception"

But this works:

public class MyConverter implements Converter<A, B> {
@Override
public B convert(A a) {
throw new RuntimeException();
}
}


Affects: 4.0.2

Referenced from: commits 035d9d5

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions